devices/e1000/e1000_main-2.6.26-ethercat.c
author Florian Pose <fp@igh.de>
Mon, 04 Sep 2017 17:12:59 +0200
branchstable-1.5
changeset 2681 9953c0d372ab
parent 2582 87e502828b3f
permissions -rw-r--r--
Adapted vm_operations_struct for kernels >= 4.11
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) {
2582
87e502828b3f Use return value of ecdev_open(); thanks to Patrick Bruenn.
Florian Pose <fp@igh-essen.com>
parents: 2471
diff changeset
  1246
		err = ecdev_open(adapter->ecdev);
87e502828b3f Use return value of ecdev_open(); thanks to Patrick Bruenn.
Florian Pose <fp@igh-essen.com>
parents: 2471
diff changeset
  1247
		if (err) {
1360
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1248
			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
  1249
			goto err_register;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1250
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1251
	} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1252
		/* 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
  1253
		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
  1254
		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
  1255
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1256
		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
  1257
		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
  1258
			goto err_register;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1261
	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
  1262
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1263
	cards_found++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1264
	return 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1265
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1266
err_register:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1267
	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
  1268
err_eeprom:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1269
	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
  1270
		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
  1271
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1272
	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
  1273
		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
  1274
err_flashmap:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1275
#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
  1276
	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
  1277
		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
  1278
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1279
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1280
	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
  1281
	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
  1282
#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
  1283
	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
  1284
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1285
err_sw_init:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1286
	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
  1287
err_ioremap:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1288
	free_netdev(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1289
err_alloc_etherdev:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1290
	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
  1291
err_pci_reg:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1292
err_dma:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1293
	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
  1294
	return err;
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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1298
 * 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
  1299
 * @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
  1300
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1301
 * 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
  1302
 * 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
  1303
 * 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
  1304
 * memory.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1305
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1306
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1307
static void __devexit
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1308
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
  1309
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1310
	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
  1311
	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
  1312
#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
  1313
	int i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1314
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1315
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1316
	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
  1317
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1318
	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
  1319
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1320
	/* 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
  1321
	 * 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
  1322
	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
  1323
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1324
#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
  1325
	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
  1326
		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
  1327
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1328
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1329
	if (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_close(adapter->ecdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1331
		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
  1332
	} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1333
		unregister_netdev(netdev);
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1336
	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
  1337
		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
  1338
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1339
	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
  1340
	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
  1341
#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
  1342
	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
  1343
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1344
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1345
	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
  1346
	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
  1347
		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
  1348
	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
  1349
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1350
	free_netdev(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1351
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1352
	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
  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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1356
 * 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
  1357
 * @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
  1358
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1359
 * 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
  1360
 * 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
  1361
 * 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
  1362
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1363
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1364
static int __devinit
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1365
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
  1366
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1367
	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
  1368
	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
  1369
	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
  1370
#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
  1371
	int i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1372
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1373
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1374
	/* 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
  1375
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1376
	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
  1377
	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
  1378
	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
  1379
	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
  1380
	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
  1381
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1382
	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
  1383
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1384
	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
  1385
	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
  1386
	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
  1387
			     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
  1388
	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
  1389
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1390
	/* identify the MAC */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1391
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1392
	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
  1393
		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
  1394
		return -EIO;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1397
	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
  1398
	default:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1399
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1400
	case e1000_82541:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1401
	case e1000_82547:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1402
	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
  1403
	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
  1404
		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
  1405
		break;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1408
	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
  1409
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1410
	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
  1411
	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
  1412
	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
  1413
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1414
	/* Copper options */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1415
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1416
	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
  1417
		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
  1418
		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
  1419
		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
  1420
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1421
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1422
	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
  1423
	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
  1424
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1425
	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
  1426
		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
  1427
		return -ENOMEM;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1430
#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
  1431
	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
  1432
		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
  1433
		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
  1434
		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
  1435
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1436
	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
  1437
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1438
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1439
	/* 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
  1440
	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
  1441
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1442
	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
  1443
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1444
	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
  1445
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1446
	return 0;
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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1450
 * 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
  1451
 * @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
  1452
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1453
 * 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
  1454
 * 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
  1455
 * 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
  1456
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1457
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1458
static int __devinit
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1459
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
  1460
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1461
	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
  1462
	                           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
  1463
	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
  1464
		return -ENOMEM;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1465
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1466
	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
  1467
	                           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
  1468
	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
  1469
		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
  1470
		return -ENOMEM;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1473
#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
  1474
	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
  1475
	                                  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
  1476
	                                  GFP_KERNEL);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1477
	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
  1478
		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
  1479
		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
  1480
		return -ENOMEM;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1481
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1482
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1483
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1484
	return E1000_SUCCESS;
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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1488
 * 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
  1489
 * @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
  1490
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1491
 * 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
  1492
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1493
 * 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
  1494
 * 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
  1495
 * 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
  1496
 * 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
  1497
 * 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
  1498
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1499
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1500
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1501
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
  1502
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1503
	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
  1504
	int err;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1505
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1506
	/* 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
  1507
	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
  1508
		return -EBUSY;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1509
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1510
	/* allocate transmit descriptors */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1511
	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
  1512
	if (err)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1513
		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
  1514
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1515
	/* allocate receive descriptors */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1516
	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
  1517
	if (err)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1518
		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
  1519
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1520
	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
  1521
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1522
	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
  1523
	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
  1524
			  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
  1525
		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
  1526
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1527
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1528
	/* 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
  1529
	 * 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
  1530
	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
  1531
	    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
  1532
		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
  1533
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1534
	/* 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
  1535
	 * 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
  1536
	 * 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
  1537
	 * 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
  1538
	e1000_configure(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1539
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1540
	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
  1541
	if (err)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1542
		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
  1543
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1544
	/* 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
  1545
	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
  1546
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1547
#ifdef CONFIG_E1000_NAPI
2469
634ba3b1eb95 Fixed possible segfault in e1000_open() function.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
  1548
	if (!adapter->ecdev) {
634ba3b1eb95 Fixed possible segfault in e1000_open() function.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
  1549
		napi_enable(&adapter->napi);
634ba3b1eb95 Fixed possible segfault in e1000_open() function.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
  1550
	}
1360
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1551
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1552
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1553
	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
  1554
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1555
	/* 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
  1556
	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
  1557
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1558
	return E1000_SUCCESS;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1559
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1560
err_req_irq:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1561
	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
  1562
	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
  1563
	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
  1564
err_setup_rx:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1565
	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
  1566
err_setup_tx:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1567
	e1000_reset(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1568
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1569
	return err;
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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1573
 * 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
  1574
 * @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
  1575
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1576
 * 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
  1577
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1578
 * 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
  1579
 * 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
  1580
 * 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
  1581
 * 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
  1582
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1583
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1584
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1585
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
  1586
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1587
	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
  1588
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1589
	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
  1590
	e1000_down(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1591
	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
  1592
	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
  1593
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_tx_resources(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1595
	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
  1596
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1597
	/* 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
  1598
	 * 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
  1599
	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
  1600
			  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
  1601
	     !(adapter->vlgrp &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1602
	       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
  1603
		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
  1604
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1605
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1606
	/* If 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
  1607
	 * 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
  1608
	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
  1609
	    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
  1610
		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
  1611
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1612
	return 0;
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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1616
 * 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
  1617
 * @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
  1618
 * @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
  1619
 * @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
  1620
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1621
static bool
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1622
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
  1623
		      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
  1624
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1625
	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
  1626
	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
  1627
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1628
	/* 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
  1629
	 * 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
  1630
	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
  1631
	    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
  1632
		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
  1633
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1634
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1635
	return true;
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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1639
 * 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
  1640
 * @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
  1641
 * @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
  1642
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1643
 * 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
  1644
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1645
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1646
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1647
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
  1648
                         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
  1649
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1650
	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
  1651
	int size;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1652
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1653
	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
  1654
	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
  1655
	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
  1656
		DPRINTK(PROBE, ERR,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1657
		"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
  1658
		return -ENOMEM;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1659
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1660
	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
  1661
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1662
	/* 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
  1663
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1664
	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
  1665
	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
  1666
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1667
	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
  1668
	if (!txdr->desc) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1669
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
  1670
		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
  1671
		DPRINTK(PROBE, ERR,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1672
		"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
  1673
		return -ENOMEM;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1676
	/* 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
  1677
	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
  1678
		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
  1679
		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
  1680
		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
  1681
				     "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
  1682
		/* 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
  1683
		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
  1684
		/* 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
  1685
		if (!txdr->desc) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1686
			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
  1687
			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
  1688
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1689
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1690
		if (!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
  1691
			/* give up */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1692
			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
  1693
					    txdr->dma);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1694
			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
  1695
			DPRINTK(PROBE, ERR,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1696
				"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
  1697
				"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
  1698
			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
  1699
			return -ENOMEM;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1700
		} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1701
			/* 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
  1702
			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
  1703
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1704
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1705
	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
  1706
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_use = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1708
	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
  1709
	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
  1710
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1711
	return 0;
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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1715
 * 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
  1716
 * 				  (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
  1717
 * @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
  1718
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1719
 * 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
  1720
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1721
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1722
int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1723
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
  1724
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1725
	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
  1726
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1727
	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
  1728
		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
  1729
		if (err) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1730
			DPRINTK(PROBE, ERR,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1731
				"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
  1732
			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
  1733
				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
  1734
							&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
  1735
			break;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1739
	return err;
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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1743
 * 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
  1744
 * @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
  1745
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1746
 * 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
  1747
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1748
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1749
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1750
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
  1751
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1752
	u64 tdba;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1753
	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
  1754
	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
  1755
	u32 ipgr1, ipgr2;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1756
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1757
	/* 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
  1758
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1759
	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
  1760
	case 1:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1761
	default:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1762
		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
  1763
		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
  1764
			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
  1765
		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
  1766
		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
  1767
		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
  1768
		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
  1769
		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
  1770
		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
  1771
		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
  1772
		break;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1775
	/* 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
  1776
	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
  1777
	    (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
  1778
	     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
  1779
		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
  1780
	else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1781
		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
  1782
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1783
	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
  1784
	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
  1785
	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
  1786
		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
  1787
		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
  1788
		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
  1789
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1790
	case e1000_80003es2lan:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1791
		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
  1792
		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
  1793
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1794
	default:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1795
		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
  1796
		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
  1797
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1798
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1799
	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
  1800
	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
  1801
	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
  1802
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1803
	/* 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
  1804
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1805
	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
  1806
	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
  1807
		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
  1808
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1809
	/* 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
  1810
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1811
	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
  1812
	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
  1813
	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
  1814
		(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
  1815
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1816
	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
  1817
		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
  1818
		/* 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
  1819
		 * gigabit link later */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1820
		tarc |= (1 << 21);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1821
		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
  1822
	} 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
  1823
		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
  1824
		tarc |= 1;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1825
		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
  1826
		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
  1827
		tarc |= 1;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1828
		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
  1829
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1830
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1831
	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
  1832
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1833
	/* 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
  1834
	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
  1835
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1836
	/* 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
  1837
	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
  1838
		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
  1839
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1840
	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
  1841
		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
  1842
	else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1843
		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
  1844
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1845
	/* 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
  1846
	 * 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
  1847
	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
  1848
	    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
  1849
		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
  1850
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1851
	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
  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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1856
 * 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
  1857
 * @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
  1858
 * @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
  1859
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1860
 * 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
  1861
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1862
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1863
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1864
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
  1865
                         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
  1866
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1867
	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
  1868
	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
  1869
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1870
	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
  1871
	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
  1872
	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
  1873
		DPRINTK(PROBE, ERR,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1874
		"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
  1875
		return -ENOMEM;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1876
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1877
	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
  1878
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1879
	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
  1880
	                        GFP_KERNEL);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1881
	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
  1882
		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
  1883
		DPRINTK(PROBE, ERR,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1884
		"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
  1885
		return -ENOMEM;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1888
	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
  1889
	                            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
  1890
	                            GFP_KERNEL);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1891
	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
  1892
		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
  1893
		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
  1894
		DPRINTK(PROBE, ERR,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1895
		"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
  1896
		return -ENOMEM;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1899
	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
  1900
		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
  1901
	else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1902
		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
  1903
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1904
	/* 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
  1905
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1906
	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
  1907
	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
  1908
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1909
	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
  1910
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1911
	if (!rxdr->desc) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1912
		DPRINTK(PROBE, ERR,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1913
		"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
  1914
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
  1915
		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
  1916
		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
  1917
		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
  1918
		return -ENOMEM;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1921
	/* 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
  1922
	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
  1923
		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
  1924
		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
  1925
		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
  1926
				     "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
  1927
		/* 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
  1928
		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
  1929
		/* 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
  1930
		if (!rxdr->desc) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1931
			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
  1932
			DPRINTK(PROBE, ERR,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1933
				"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
  1934
				"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
  1935
			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
  1936
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1937
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1938
		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
  1939
			/* give up */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1940
			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
  1941
					    rxdr->dma);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1942
			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
  1943
			DPRINTK(PROBE, ERR,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1944
				"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
  1945
				"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
  1946
			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
  1947
		} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1948
			/* 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
  1949
			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
  1950
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1951
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1952
	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
  1953
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_clean = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1955
	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
  1956
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1957
	return 0;
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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1961
 * 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
  1962
 * 				  (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
  1963
 * @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
  1964
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1965
 * 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
  1966
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1967
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1968
int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1969
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
  1970
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1971
	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
  1972
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1973
	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
  1974
		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
  1975
		if (err) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1976
			DPRINTK(PROBE, ERR,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1977
				"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
  1978
			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
  1979
				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
  1980
							&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
  1981
			break;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1985
	return err;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1986
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1987
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1988
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1989
 * 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
  1990
 * @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
  1991
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1992
#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
  1993
			(((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
  1994
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1995
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
  1996
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1997
	u32 rctl, rfctl;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1998
	u32 psrctl = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1999
#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
  2000
	u32 pages = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2001
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2002
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2003
	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
  2004
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2005
	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
  2006
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2007
	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
  2008
		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
  2009
		(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
  2010
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2011
	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
  2012
		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
  2013
	else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2014
		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
  2015
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2016
	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
  2017
		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
  2018
	else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2019
		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
  2020
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2021
	/* Setup buffer sizes */
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_SZ_4096;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2023
	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
  2024
	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
  2025
		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
  2026
			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
  2027
			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
  2028
			break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2029
		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
  2030
			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
  2031
			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
  2032
			break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2033
		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
  2034
			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
  2035
			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
  2036
			break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2037
		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
  2038
		default:
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_SZ_2048;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2040
			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
  2041
			break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2042
		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
  2043
			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
  2044
			break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2045
		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
  2046
			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
  2047
			break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2048
		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
  2049
			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
  2050
			break;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2053
#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
  2054
	/* 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
  2055
	 * 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
  2056
	 * 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
  2057
	 * 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
  2058
	 * 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
  2059
	 * 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
  2060
	 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2061
	/* 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
  2062
	 * 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
  2063
	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
  2064
	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
  2065
	    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
  2066
		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
  2067
	else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2068
		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
  2069
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2070
	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
  2071
		/* 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
  2072
		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
  2073
		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
  2074
		/* 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
  2075
		 * 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
  2076
		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
  2077
		          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
  2078
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2079
		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
  2080
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2081
		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
  2082
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2083
		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
  2084
			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
  2085
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2086
		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
  2087
		case 3:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2088
			psrctl |= PAGE_SIZE <<
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2089
				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
  2090
		case 2:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2091
			psrctl |= PAGE_SIZE <<
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2092
				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
  2093
		case 1:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2094
			psrctl |= PAGE_SIZE >>
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2095
				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
  2096
			break;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2099
		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
  2100
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2101
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2102
	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
  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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2106
 * 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
  2107
 * @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
  2108
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2109
 * 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
  2110
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2111
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2112
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2113
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
  2114
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2115
	u64 rdba;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2116
	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
  2117
	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
  2118
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2119
	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
  2120
		/* 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
  2121
		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
  2122
			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
  2123
		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
  2124
		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
  2125
	} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2126
		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
  2127
			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
  2128
		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
  2129
		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
  2130
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2131
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2132
	/* 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
  2133
	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
  2134
	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
  2135
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2136
	/* 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
  2137
	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
  2138
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2139
	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
  2140
		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
  2141
		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
  2142
			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
  2143
				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
  2144
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2145
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2146
	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
  2147
		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
  2148
		/* 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
  2149
		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
  2150
#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
  2151
		/* 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
  2152
		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
  2153
		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
  2154
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2155
		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
  2156
		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
  2157
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2158
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2159
	/* 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
  2160
	 * 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
  2161
	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
  2162
	case 1:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2163
	default:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2164
		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
  2165
		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
  2166
		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
  2167
		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
  2168
		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
  2169
		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
  2170
		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
  2171
		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
  2172
		break;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2175
	/* 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
  2176
	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
  2177
		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
  2178
		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
  2179
			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
  2180
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2181
			/* 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
  2182
			 * 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
  2183
			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
  2184
			    (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
  2185
				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
  2186
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2187
		} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2188
			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
  2189
			/* 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
  2190
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2191
		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
  2192
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2193
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2194
	/* 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
  2195
	 * 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
  2196
#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
  2197
	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
  2198
		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
  2199
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2200
	/* Enable Receives */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2201
	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
  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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2205
 * 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
  2206
 * @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
  2207
 * @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
  2208
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2209
 * 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
  2210
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2211
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2212
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2213
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
  2214
                        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
  2215
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2216
	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
  2217
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2218
	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
  2219
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2220
	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
  2221
	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
  2222
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2223
	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
  2224
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2225
	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
  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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2229
 * 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
  2230
 * @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
  2231
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2232
 * 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
  2233
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2234
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2235
void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2236
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
  2237
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2238
	int i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2239
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2240
	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
  2241
		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
  2242
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2243
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2244
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2245
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
  2246
			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
  2247
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2248
	if (adapter->ecdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2249
		return;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2250
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2251
	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
  2252
		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
  2253
				buffer_info->dma,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2254
				buffer_info->length,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2255
				PCI_DMA_TODEVICE);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2256
		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
  2257
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2258
	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
  2259
		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
  2260
		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
  2261
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2262
	/* 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
  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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2266
 * 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
  2267
 * @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
  2268
 * @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
  2269
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2270
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2271
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2272
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
  2273
                    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
  2274
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2275
	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
  2276
	unsigned long size;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2277
	unsigned int i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2278
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2279
	/* 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
  2280
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2281
	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
  2282
		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
  2283
		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
  2284
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2285
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2286
	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
  2287
	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
  2288
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2289
	/* 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
  2290
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2291
	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
  2292
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_use = 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->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
  2295
	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
  2296
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->tdh);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2298
	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
  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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2302
 * 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
  2303
 * @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
  2304
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2305
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2306
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2307
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
  2308
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2309
	int i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2310
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2311
	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
  2312
		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
  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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2316
 * 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
  2317
 * @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
  2318
 * @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
  2319
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2320
 * 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
  2321
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2322
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2323
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2324
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
  2325
                        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
  2326
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2327
	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
  2328
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2329
	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
  2330
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2331
	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
  2332
	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
  2333
	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
  2334
	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
  2335
	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
  2336
	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
  2337
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2338
	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
  2339
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2340
	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
  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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2344
 * 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
  2345
 * @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
  2346
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2347
 * 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
  2348
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2349
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2350
void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2351
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
  2352
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2353
	int i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2354
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2355
	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
  2356
		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
  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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2360
 * 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
  2361
 * @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
  2362
 * @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
  2363
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2364
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2365
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2366
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
  2367
                    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
  2368
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2369
	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
  2370
	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
  2371
	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
  2372
	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
  2373
	unsigned long size;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2374
	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
  2375
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2376
	/* 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
  2377
	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
  2378
		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
  2379
		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
  2380
			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
  2381
					 buffer_info->dma,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2382
					 buffer_info->length,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2383
					 PCI_DMA_FROMDEVICE);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2384
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2385
			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
  2386
			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
  2387
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2388
		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
  2389
		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
  2390
		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
  2391
			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
  2392
			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
  2393
				       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
  2394
				       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
  2395
			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
  2396
			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
  2397
			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
  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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2401
	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
  2402
	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
  2403
	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
  2404
	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
  2405
	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
  2406
	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
  2407
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2408
	/* 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
  2409
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2410
	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
  2411
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_clean = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2413
	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
  2414
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->rdh);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2416
	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
  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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2420
 * 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
  2421
 * @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
  2422
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2423
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2424
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2425
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
  2426
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2427
	int i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2428
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2429
	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
  2430
		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
  2431
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2432
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2433
/* 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
  2434
 * 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
  2435
 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2436
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2437
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
  2438
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2439
	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
  2440
	u32 rctl;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2441
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2442
	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
  2443
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2444
	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
  2445
	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
  2446
	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
  2447
	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
  2448
	mdelay(5);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2449
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2450
	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
  2451
		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
  2452
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2453
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2454
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2455
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
  2456
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2457
	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
  2458
	u32 rctl;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2459
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2460
	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
  2461
	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
  2462
	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
  2463
	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
  2464
	mdelay(5);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2465
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2466
	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
  2467
		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
  2468
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2469
	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
  2470
		/* 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
  2471
		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
  2472
		e1000_configure_rx(adapter);
2421
bc2d4bf9cbe5 Removed trailing spaces.
Florian Pose <fp@igh-essen.com>
parents: 2050
diff changeset
  2473
		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
  2474
			/* 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
  2475
			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
  2476
		} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2477
            /* 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
  2478
			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
  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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2485
 * 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
  2486
 * @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
  2487
 * @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
  2488
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2489
 * 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
  2490
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2491
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2492
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2493
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
  2494
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2495
	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
  2496
	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
  2497
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2498
	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
  2499
		return -EADDRNOTAVAIL;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2500
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2501
	/* 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
  2502
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2503
	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
  2504
		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
  2505
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2506
	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
  2507
	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
  2508
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2509
	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
  2510
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2511
	/* 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
  2512
	 * 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
  2513
	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
  2514
		/* 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
  2515
		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
  2516
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2517
		/* 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
  2518
		 * 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
  2519
		 * 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
  2520
		 * 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
  2521
		 * 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
  2522
		 * RAR[14] */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2523
		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
  2524
					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
  2525
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2526
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2527
	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
  2528
		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
  2529
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2530
	return 0;
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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2534
 * 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
  2535
 * @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
  2536
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2537
 * 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
  2538
 * 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
  2539
 * 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
  2540
 * 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
  2541
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2542
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2543
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2544
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
  2545
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2546
	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
  2547
	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
  2548
	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
  2549
	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
  2550
	u32 rctl;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2551
	u32 hash_value;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2552
	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
  2553
	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
  2554
				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
  2555
				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
  2556
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2557
	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
  2558
		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
  2559
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2560
	/* 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
  2561
	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
  2562
		rar_entries--;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2563
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2564
	/* 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
  2565
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2566
	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
  2567
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2568
	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
  2569
		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
  2570
	} 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
  2571
		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
  2572
	} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2573
		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
  2574
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2575
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2576
	uc_ptr = NULL;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2577
	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
  2578
		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
  2579
	} 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
  2580
		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
  2581
		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
  2582
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2583
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2584
	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
  2585
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2586
	/* 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
  2587
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2588
	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
  2589
		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
  2590
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2591
	/* 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
  2592
	 * 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
  2593
	 * when possible.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2594
	 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2595
	 * 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
  2596
	 * 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
  2597
	 * -- 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
  2598
	 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2599
	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
  2600
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2601
	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
  2602
		if (uc_ptr) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2603
			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
  2604
			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
  2605
		} 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
  2606
			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
  2607
			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
  2608
		} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2609
			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
  2610
			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
  2611
			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
  2612
			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
  2613
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2614
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2615
	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
  2616
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2617
	/* 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
  2618
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2619
	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
  2620
		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
  2621
		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
  2622
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2623
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2624
	/* 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
  2625
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2626
	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
  2627
		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
  2628
		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
  2629
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2630
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2631
	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
  2632
		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
  2633
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2634
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2635
/* 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
  2636
 * the phy */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2637
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2638
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2639
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
  2640
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2641
	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
  2642
	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
  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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2646
 * 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
  2647
 * @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
  2648
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2649
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2650
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2651
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
  2652
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2653
	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
  2654
	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
  2655
	u32 tctl;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2656
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2657
	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
  2658
		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
  2659
		    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
  2660
		   (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
  2661
		    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
  2662
		   (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
  2663
		    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
  2664
			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
  2665
			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
  2666
					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
  2667
			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
  2668
					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
  2669
			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
  2670
					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
  2671
			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
  2672
					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
  2673
			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
  2674
					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
  2675
			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
  2676
			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
  2677
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2678
			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
  2679
			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
  2680
			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
  2681
		} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2682
			if (!adapter->ecdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2683
				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
  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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2689
 * 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
  2690
 * @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
  2691
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2692
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2693
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
  2694
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2695
	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
  2696
	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
  2697
	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
  2698
	u32 link, tctl;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2699
	s32 ret_val;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2700
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2701
	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
  2702
	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
  2703
	    (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
  2704
	    (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
  2705
		/* 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
  2706
		DPRINTK(LINK, INFO,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2707
			"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
  2708
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2709
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2710
	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
  2711
		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
  2712
		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
  2713
			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
  2714
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2715
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2716
	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
  2717
	   !(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
  2718
		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
  2719
	else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2720
		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
  2721
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2722
	if (link) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2723
		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
  2724
				|| (!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
  2725
			u32 ctrl;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2726
			bool txb2b = true;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2727
			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
  2728
			                           &adapter->link_speed,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2729
			                           &adapter->link_duplex);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2730
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2731
			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
  2732
			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
  2733
			        "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
  2734
			        adapter->link_speed,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2735
			        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
  2736
			        "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
  2737
			        ((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
  2738
			        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
  2739
			        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
  2740
			        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
  2741
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2742
			/* 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
  2743
			 * 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
  2744
			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
  2745
			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
  2746
			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
  2747
			case SPEED_10:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2748
				txb2b = false;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2749
				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
  2750
				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
  2751
				break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2752
			case SPEED_100:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2753
				txb2b = false;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2754
				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
  2755
				/* 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
  2756
				break;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2759
			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
  2760
			     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
  2761
			    !txb2b) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2762
				u32 tarc0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2763
				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
  2764
				tarc0 &= ~(1 << 21);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2765
				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
  2766
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2767
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2768
			/* 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
  2769
			 * some hardware issues */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2770
			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
  2771
			    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
  2772
				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
  2773
				case SPEED_10:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2774
				case SPEED_100:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2775
					DPRINTK(PROBE,INFO,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2776
				        "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
  2777
					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
  2778
					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
  2779
					break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2780
				case SPEED_1000:
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_TSO;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2782
					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
  2783
					break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2784
				default:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2785
					/* oops */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2786
					break;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2790
			/* 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
  2791
			 * after setting TARC0 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2792
			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
  2793
			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
  2794
			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
  2795
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2796
			if (adapter->ecdev) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2797
				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
  2798
			} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2799
				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
  2800
				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
  2801
				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
  2802
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2803
			adapter->smartspeed = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2804
		} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2805
			/* 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
  2806
			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
  2807
				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
  2808
				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
  2809
				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
  2810
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2811
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2812
	} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2813
		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
  2814
				|| (!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
  2815
			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
  2816
			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
  2817
			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
  2818
			if (adapter->ecdev) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2819
				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
  2820
			} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2821
				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
  2822
				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
  2823
				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
  2824
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2825
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2826
			/* 80003ES2LAN workaround--
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2827
			 * 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
  2828
			 * 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
  2829
			 * 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
  2830
			 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2831
			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
  2832
				/* reset device */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2833
				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
  2834
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2835
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2836
		e1000_smartspeed(adapter);
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2839
	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
  2840
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2841
	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
  2842
	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
  2843
	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
  2844
	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
  2845
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2846
	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
  2847
	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
  2848
	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
  2849
	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
  2850
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2851
	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
  2852
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2853
	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
  2854
		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
  2855
			/* 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
  2856
			 * 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
  2857
			 * 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
  2858
			 * (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
  2859
			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
  2860
			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
  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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2864
	/* 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
  2865
	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
  2866
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2867
	/* 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
  2868
	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
  2869
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2870
	/* 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
  2871
	 * 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
  2872
	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
  2873
		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
  2874
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2875
	/* Reset the timer */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2876
	if (!adapter->ecdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2877
		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
  2878
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2879
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2880
enum latency_range {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2881
	lowest_latency = 0,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2882
	low_latency = 1,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2883
	bulk_latency = 2,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2884
	latency_invalid = 255
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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2888
 * 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
  2889
 *      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
  2890
 *      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
  2891
 *      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
  2892
 *      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
  2893
 *      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
  2894
 *      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
  2895
 *      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
  2896
 *      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
  2897
 *      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
  2898
 * @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
  2899
 * @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
  2900
 * @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
  2901
 * @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
  2902
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2903
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
  2904
                                   u16 itr_setting,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2905
                                   int packets,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2906
                                   int bytes)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2907
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2908
	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
  2909
	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
  2910
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2911
	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
  2912
		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
  2913
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2914
	if (packets == 0)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2915
		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
  2916
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2917
	switch (itr_setting) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2918
	case lowest_latency:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2919
		/* 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
  2920
		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
  2921
			retval = bulk_latency;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2922
		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
  2923
			retval = low_latency;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2924
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2925
	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
  2926
		if (bytes > 10000) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2927
			/* 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
  2928
			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
  2929
				retval = bulk_latency;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2930
			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
  2931
				retval = bulk_latency;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2932
			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
  2933
				retval = lowest_latency;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2934
		} 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
  2935
			retval = bulk_latency;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2936
		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
  2937
			retval = lowest_latency;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2938
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2939
	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
  2940
		if (bytes > 25000) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2941
			if (packets > 35)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2942
				retval = low_latency;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2943
		} 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
  2944
			retval = low_latency;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2945
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2946
		break;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2949
update_itr_done:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2950
	return retval;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2953
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
  2954
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2955
	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
  2956
	u16 current_itr;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2957
	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
  2958
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2959
	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
  2960
		return;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2961
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2962
	/* 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
  2963
	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
  2964
		current_itr = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2965
		new_itr = 4000;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2966
		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
  2967
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2968
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 = 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
  2970
	                            adapter->tx_itr,
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_packets,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2972
	                            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
  2973
	/* 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
  2974
	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
  2975
		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
  2976
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 = 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
  2978
	                            adapter->rx_itr,
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_packets,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2980
	                            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
  2981
	/* 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
  2982
	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
  2983
		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
  2984
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2985
	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
  2986
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2987
	switch (current_itr) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2988
	/* 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
  2989
	case lowest_latency:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2990
		new_itr = 70000;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2991
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2992
	case low_latency:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2993
		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
  2994
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2995
	case bulk_latency:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2996
		new_itr = 4000;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2997
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2998
	default:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2999
		break;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3002
set_itr_now:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3003
	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
  3004
		/* 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
  3005
		 * 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
  3006
		 * increasing */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3007
		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
  3008
		             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
  3009
		             new_itr;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3010
		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
  3011
		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
  3012
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3013
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3014
	return;
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
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_CSUM		0x00000001
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_VLAN		0x00000002
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_TSO		0x00000004
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_IPV4		0x00000008
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_MASK	0xffff0000
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3022
#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
  3023
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3024
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3025
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
  3026
          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
  3027
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3028
	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
  3029
	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
  3030
	unsigned int i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3031
	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
  3032
	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
  3033
	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
  3034
	int err;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3035
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3036
	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
  3037
		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
  3038
			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
  3039
			if (err)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3040
				return err;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3043
		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
  3044
		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
  3045
		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
  3046
			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
  3047
			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
  3048
			iph->check = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3049
			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
  3050
								 iph->daddr, 0,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3051
								 IPPROTO_TCP,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3052
								 0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3053
			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
  3054
			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
  3055
		} 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
  3056
			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
  3057
			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
  3058
				~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
  3059
						 &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
  3060
						 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
  3061
			ipcse = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3062
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3063
		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
  3064
		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
  3065
		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
  3066
		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
  3067
		tucse = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3068
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3069
		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
  3070
			       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
  3071
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3072
		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
  3073
		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
  3074
		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
  3075
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.ipcss  = ipcss;
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.ipcso  = ipcso;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3078
		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
  3079
		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
  3080
		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
  3081
		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
  3082
		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
  3083
		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
  3084
		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
  3085
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3086
		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
  3087
		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
  3088
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3089
		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
  3090
		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
  3091
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3092
		return true;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3093
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3094
	return false;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3097
static bool
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3098
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
  3099
              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
  3100
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3101
	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
  3102
	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
  3103
	unsigned int i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3104
	u8 css;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3105
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3106
	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
  3107
		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
  3108
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3109
		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
  3110
		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
  3111
		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
  3112
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3113
		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
  3114
		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
  3115
		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
  3116
			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
  3117
		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
  3118
		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
  3119
		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
  3120
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3121
		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
  3122
		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
  3123
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3124
		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
  3125
		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
  3126
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3127
		return true;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3130
	return false;
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
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_TXD_PWR	12
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3134
#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
  3135
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3136
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3137
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
  3138
             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
  3139
             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
  3140
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3141
	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
  3142
	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
  3143
	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
  3144
	unsigned int f;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3145
	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
  3146
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3147
	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
  3148
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3149
	while (len) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3150
		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
  3151
		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
  3152
		/* 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
  3153
		 * 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
  3154
		 * 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
  3155
		 * 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
  3156
		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
  3157
		    !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
  3158
			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
  3159
			size -= 4;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3162
		/* 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
  3163
		 * 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
  3164
		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
  3165
			size -= 4;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3166
		/* 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
  3167
		 * 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
  3168
		 * 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
  3169
		 * 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
  3170
		 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3171
		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
  3172
		                (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
  3173
		        size = 2015;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3174
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3175
		/* 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
  3176
		 * 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
  3177
		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
  3178
		   !((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
  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
			size -= 4;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3181
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3182
		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
  3183
		buffer_info->dma =
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3184
			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
  3185
				skb->data + offset,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3186
				size,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3187
				PCI_DMA_TODEVICE);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3188
		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
  3189
		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
  3190
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3191
		len -= size;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3192
		offset += size;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3193
		count++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3194
		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
  3195
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3196
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3197
	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
  3198
		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
  3199
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3200
		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
  3201
		len = frag->size;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3202
		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
  3203
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3204
		while (len) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3205
			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
  3206
			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
  3207
			/* 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
  3208
			 * 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
  3209
			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
  3210
				size -= 4;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3211
			/* 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
  3212
			 * 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
  3213
			 * dwords. */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3214
			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
  3215
			   !((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
  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
				size -= 4;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3218
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3219
			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
  3220
			buffer_info->dma =
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3221
				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
  3222
					frag->page,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3223
					offset,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3224
					size,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3225
					PCI_DMA_TODEVICE);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3226
			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
  3227
			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
  3228
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3229
			len -= size;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3230
			offset += size;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3231
			count++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3232
			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
  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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3236
	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
  3237
	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
  3238
	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
  3239
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3240
	return count;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3243
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3244
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
  3245
               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
  3246
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3247
	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
  3248
	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
  3249
	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
  3250
	unsigned int i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3251
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3252
	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
  3253
		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
  3254
		             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
  3255
		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
  3256
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3257
		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
  3258
			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
  3259
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3260
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3261
	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
  3262
		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
  3263
		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
  3264
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3265
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3266
	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
  3267
		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
  3268
		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
  3269
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3270
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3271
	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
  3272
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3273
	while (count--) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3274
		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
  3275
		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
  3276
		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
  3277
		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
  3278
			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
  3279
		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
  3280
		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
  3281
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3282
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3283
	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
  3284
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3285
	/* 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
  3286
	 * 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
  3287
	 * 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
  3288
	 * 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
  3289
	wmb();
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3290
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3291
	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
  3292
	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
  3293
	/* 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
  3294
	 * 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
  3295
	mmiowb();
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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3299
 * 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
  3300
 * 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
  3301
 * 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
  3302
 * 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
  3303
 * 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
  3304
 * 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
  3305
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3306
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3307
#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
  3308
#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
  3309
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3310
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3311
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
  3312
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3313
	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
  3314
	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
  3315
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3316
	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
  3317
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3318
	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
  3319
		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
  3320
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3321
	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
  3322
		return 1;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3323
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3324
	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
  3325
		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
  3326
		return 1;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3329
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
  3330
	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
  3331
	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
  3332
		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
  3333
	return 0;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3336
#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
  3337
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3338
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
  3339
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3340
	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
  3341
	u16 length, offset;
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_present(skb)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3343
		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
  3344
			( 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
  3345
			  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
  3346
			return 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3347
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3348
	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
  3349
		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
  3350
		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
  3351
			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
  3352
				(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
  3353
			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
  3354
				struct udphdr *udp =
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3355
					(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
  3356
						(ip->ihl << 2));
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3357
				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
  3358
					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
  3359
					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
  3360
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3361
					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
  3362
							(u8 *)udp + 8,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3363
							length);
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
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3368
	return 0;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3371
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
  3372
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3373
	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
  3374
	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
  3375
2471
fc64a4b1ec1a Fixed __e1000_maybe_stop_tx().
Florian Pose <fp@igh-essen.com>
parents: 2469
diff changeset
  3376
	if (adapter->ecdev) {
fc64a4b1ec1a Fixed __e1000_maybe_stop_tx().
Florian Pose <fp@igh-essen.com>
parents: 2469
diff changeset
  3377
		return -EBUSY;
fc64a4b1ec1a Fixed __e1000_maybe_stop_tx().
Florian Pose <fp@igh-essen.com>
parents: 2469
diff changeset
  3378
	}
fc64a4b1ec1a Fixed __e1000_maybe_stop_tx().
Florian Pose <fp@igh-essen.com>
parents: 2469
diff changeset
  3379
1360
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3380
	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
  3381
	/* 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
  3382
	 *  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
  3383
	 * 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
  3384
	smp_mb();
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3385
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3386
	/* 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
  3387
	 * made room available. */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3388
	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
  3389
		return -EBUSY;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3390
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3391
	/* A reprieve! */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3392
	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
  3393
	++adapter->restart_queue;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3394
	return 0;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3397
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
  3398
                               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
  3399
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3400
	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
  3401
		return 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3402
	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
  3403
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3404
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3405
#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
  3406
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3407
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
  3408
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3409
	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
  3410
	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
  3411
	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
  3412
	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
  3413
	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
  3414
	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
  3415
	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
  3416
	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
  3417
	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
  3418
	int count = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3419
	int tso;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3420
	unsigned int f;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3421
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3422
	/* 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
  3423
	 * 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
  3424
	 * 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
  3425
	 * 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
  3426
	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
  3427
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3428
	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
  3429
		if (!adapter->ecdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3430
			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
  3431
		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
  3432
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3433
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3434
	/* 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
  3435
	 * length to 4kB */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3436
	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
  3437
		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
  3438
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3439
	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
  3440
	/* 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
  3441
	 * 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
  3442
	 * 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
  3443
	 * 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
  3444
	 * 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
  3445
	 * drops. */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3446
	if (mss) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3447
		u8 hdr_len;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3448
		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
  3449
		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
  3450
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3451
		/* 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
  3452
		* 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
  3453
		* 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
  3454
		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
  3455
		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
  3456
			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
  3457
				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
  3458
			case e1000_82544:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3459
				/* 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
  3460
				 * 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
  3461
				 * 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
  3462
				 * 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
  3463
				 * 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
  3464
				 * 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
  3465
				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
  3466
					break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3467
				/* fall through */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3468
			case e1000_82571:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3469
			case e1000_82572:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3470
			case e1000_82573:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3471
			case e1000_ich8lan:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3472
				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
  3473
				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
  3474
					DPRINTK(DRV, ERR,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3475
						"__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
  3476
					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
  3477
					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
  3478
				}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3479
				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
  3480
				break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3481
			default:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3482
				/* do nothing */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3483
				break;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3488
	/* 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
  3489
	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
  3490
		count++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3491
	count++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3492
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3493
	/* Controller Erratum workaround */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3494
	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
  3495
		count++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3496
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3497
	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
  3498
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3499
	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
  3500
		count++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3501
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3502
	/* 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
  3503
	 * 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
  3504
	 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3505
	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
  3506
			(len > 2015)))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3507
		count++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3508
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3509
	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
  3510
	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
  3511
		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
  3512
				       max_txd_pwr);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3513
	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
  3514
		count += nr_frags;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3517
	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
  3518
	    (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
  3519
		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
  3520
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3521
	if (!adapter->ecdev &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3522
			!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
  3523
		/* 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
  3524
		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
  3525
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3526
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3527
	/* 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
  3528
	 * 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
  3529
	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
  3530
		if (!adapter->ecdev) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3531
			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
  3532
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3533
		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
  3534
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3535
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3536
	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
  3537
		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
  3538
			if (!adapter->ecdev) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3539
				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
  3540
				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
  3541
				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
  3542
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3543
			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
  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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3547
	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
  3548
		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
  3549
		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
  3550
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3551
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3552
	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
  3553
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3554
	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
  3555
	if (tso < 0) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3556
		if (!adapter->ecdev) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3557
			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
  3558
			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
  3559
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3560
		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
  3561
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3562
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3563
	if (likely(tso)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3564
		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
  3565
		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
  3566
	} 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
  3567
		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
  3568
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3569
	/* 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
  3570
	 * 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
  3571
	 * 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
  3572
	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
  3573
		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
  3574
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3575
	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
  3576
	               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
  3577
	                            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
  3578
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3579
	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
  3580
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3581
	if (!adapter->ecdev) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3582
		/* 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
  3583
		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
  3584
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3585
		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
  3586
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3587
	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
  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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3591
 * 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
  3592
 * @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
  3593
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3594
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3595
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3596
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
  3597
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3598
	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
  3599
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3600
	/* 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
  3601
	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
  3602
	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
  3603
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3604
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3605
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3606
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
  3607
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3608
	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
  3609
		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
  3610
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3611
	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
  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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3615
 * 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
  3616
 * @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
  3617
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3618
 * 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
  3619
 * 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
  3620
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3621
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3622
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
  3623
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
  3624
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3625
	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
  3626
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3627
	/* 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
  3628
	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
  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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3632
 * 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
  3633
 * @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
  3634
 * @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
  3635
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3636
 * 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
  3637
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3638
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3639
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3640
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
  3641
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3642
	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
  3643
	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
  3644
	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
  3645
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3646
	if (adapter->ecdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3647
		return -EBUSY;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3648
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3649
	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
  3650
	    (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
  3651
		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
  3652
		return -EINVAL;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3655
	/* 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
  3656
	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
  3657
	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
  3658
	case e1000_ich8lan:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3659
		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
  3660
			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
  3661
			return -EINVAL;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3662
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3663
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3664
	case e1000_82573:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3665
		/* 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
  3666
		 * - 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
  3667
		 * - 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
  3668
		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
  3669
		                  &eeprom_data);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3670
		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
  3671
		    (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
  3672
			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
  3673
				DPRINTK(PROBE, ERR,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3674
			            	"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
  3675
				return -EINVAL;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3676
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3677
			break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3678
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3679
		/* 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
  3680
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3681
		/* 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
  3682
	case e1000_82571:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3683
	case e1000_82572:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3684
	case e1000_80003es2lan:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3685
#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
  3686
		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
  3687
			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
  3688
			return -EINVAL;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3689
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3690
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3691
	default:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3692
		/* 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
  3693
		break;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3696
	/* 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
  3697
	 * 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
  3698
	 * larger slab size
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3699
	 * 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
  3700
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3701
	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
  3702
		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
  3703
	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
  3704
		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
  3705
	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
  3706
		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
  3707
	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
  3708
		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
  3709
	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
  3710
		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
  3711
	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
  3712
		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
  3713
	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
  3714
		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
  3715
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3716
	/* 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
  3717
	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
  3718
	    ((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
  3719
	     (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
  3720
		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
  3721
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3722
	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
  3723
	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
  3724
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3725
	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
  3726
		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
  3727
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3728
	return 0;
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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3732
 * 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
  3733
 * @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
  3734
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3735
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3736
void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3737
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
  3738
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3739
	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
  3740
	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
  3741
	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
  3742
	u16 phy_tmp;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3743
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3744
#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
  3745
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3746
	/*
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3747
	 * 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
  3748
	 * connection is down.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3749
	 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3750
	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
  3751
		return;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3752
	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
  3753
		return;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3754
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3755
	if (!adapter->ecdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3756
		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
  3757
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3758
	/* 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
  3759
	 * 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
  3760
	 * 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
  3761
	 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3762
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3763
	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
  3764
	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
  3765
	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
  3766
	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
  3767
	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
  3768
	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
  3769
	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
  3770
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3771
	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
  3772
		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
  3773
		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
  3774
		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
  3775
		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
  3776
		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
  3777
		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
  3778
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3779
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3780
	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
  3781
	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
  3782
	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
  3783
	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
  3784
	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
  3785
	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
  3786
	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
  3787
	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
  3788
	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
  3789
	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
  3790
	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
  3791
	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
  3792
	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
  3793
	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
  3794
	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
  3795
	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
  3796
	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
  3797
	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
  3798
	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
  3799
	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
  3800
	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
  3801
	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
  3802
	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
  3803
	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
  3804
	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
  3805
	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
  3806
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3807
	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
  3808
		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
  3809
		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
  3810
		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
  3811
		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
  3812
		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
  3813
		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
  3814
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3815
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3816
	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
  3817
	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
  3818
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3819
	/* 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
  3820
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3821
	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
  3822
	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
  3823
	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
  3824
	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
  3825
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3826
	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
  3827
		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
  3828
		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
  3829
		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
  3830
		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
  3831
		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
  3832
		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
  3833
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3834
	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
  3835
		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
  3836
		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
  3837
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3838
		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
  3839
			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
  3840
			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
  3841
			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
  3842
			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
  3843
			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
  3844
			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
  3845
			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
  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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3849
	/* 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
  3850
	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
  3851
	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
  3852
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3853
	/* Rx Errors */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3854
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3855
	/* 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
  3856
	* 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
  3857
	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
  3858
		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
  3859
		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
  3860
		adapter->stats.cexterr;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3861
	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
  3862
	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
  3863
	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
  3864
	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
  3865
	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
  3866
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3867
	/* Tx Errors */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3868
	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
  3869
	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
  3870
	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
  3871
	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
  3872
	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
  3873
	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
  3874
	    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
  3875
		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
  3876
		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
  3877
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3878
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3879
	/* 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
  3880
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3881
	/* Phy Stats */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3882
	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
  3883
		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
  3884
		   (!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
  3885
			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
  3886
			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
  3887
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3888
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3889
		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
  3890
		   (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
  3891
		   !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
  3892
			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
  3893
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3894
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3895
	/* Management Stats */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3896
	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
  3897
		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
  3898
		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
  3899
		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
  3900
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3901
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3902
	if (!adapter->ecdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3903
		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
  3904
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3905
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3906
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
  3907
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3908
    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
  3909
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3910
    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
  3911
        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
  3912
        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
  3913
    }
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3914
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3915
#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
  3916
	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
  3917
#else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3918
    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
  3919
#endif
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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3923
 * 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
  3924
 * @irq: interrupt number
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3925
 * @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
  3926
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3927
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3928
static irqreturn_t
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3929
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
  3930
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3931
	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
  3932
	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
  3933
	struct e1000_hw *hw = &adapter->hw;
2421
bc2d4bf9cbe5 Removed trailing spaces.
Florian Pose <fp@igh-essen.com>
parents: 2050
diff changeset
  3934
1360
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3935
	int i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3936
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3937
	if (adapter->ecdev) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3938
#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
  3939
		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
  3940
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3941
		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
  3942
#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
  3943
			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
  3944
                            &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
  3945
						!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
  3946
#else
2050
a3e59f2a8589 Changed accidentally used & operator to &&.
Florian Pose <fp@igh-essen.com>
parents: 1360
diff changeset
  3947
			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
  3948
						!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
  3949
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3950
				break;
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
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3953
	} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3954
		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
  3955
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3956
		/* 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
  3957
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3958
		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
  3959
			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
  3960
			/* 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
  3961
			 * 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
  3962
			 * adapter in watchdog */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3963
			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
  3964
			    (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
  3965
				/* disable receives */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3966
				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
  3967
				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
  3968
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3969
			/* 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
  3970
			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
  3971
				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
  3972
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3973
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3974
#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
  3975
		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
  3976
			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
  3977
			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
  3978
			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
  3979
			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
  3980
			__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
  3981
		} else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3982
			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
  3983
#else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3984
		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
  3985
		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
  3986
		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
  3987
		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
  3988
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3989
		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
  3990
			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
  3991
			   !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
  3992
				break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3993
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3994
		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
  3995
			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
  3996
#endif
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3999
	return IRQ_HANDLED;
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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4003
 * 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
  4004
 * @irq: interrupt number
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4005
 * @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
  4006
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4007
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4008
static irqreturn_t
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4009
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
  4010
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4011
	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
  4012
	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
  4013
	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
  4014
	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
  4015
	int i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4016
	if (unlikely(!icr))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4017
		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
  4018
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4019
#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
  4020
	/* 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
  4021
	 * 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
  4022
	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
  4023
	             !(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
  4024
		return IRQ_NONE;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4025
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4026
	/* 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
  4027
	 * 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
  4028
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4029
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4030
	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
  4031
		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
  4032
		/* 80003ES2LAN workaround--
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4033
		 * 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
  4034
		 * 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
  4035
		 * 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
  4036
		 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4037
		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
  4038
		    (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
  4039
			/* disable receives */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4040
			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
  4041
			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
  4042
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4043
		/* 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
  4044
		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
  4045
			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
  4046
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4047
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4048
	if (adapter->ecdev) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4049
#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
  4050
			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
  4051
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4052
			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
  4053
#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
  4054
				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
  4055
		                    &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
  4056
							!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
  4057
#else
2050
a3e59f2a8589 Changed accidentally used & operator to &&.
Florian Pose <fp@igh-essen.com>
parents: 1360
diff changeset
  4058
				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
  4059
							!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
  4060
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4061
					break;
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
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4064
	} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4065
#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
  4066
		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
  4067
			/* 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
  4068
			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
  4069
			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
  4070
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4071
		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
  4072
			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
  4073
			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
  4074
			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
  4075
			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
  4076
			__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
  4077
		} else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4078
			/* 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
  4079
			 * 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
  4080
			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
  4081
#else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4082
		/* 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
  4083
		 * 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
  4084
		 * 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
  4085
		 * 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
  4086
		 * 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
  4087
		 * 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
  4088
		 * 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
  4089
		 * 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
  4090
		 * de-assertion state.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4091
		 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4092
		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
  4093
			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
  4094
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4095
		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
  4096
		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
  4097
		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
  4098
		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
  4099
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4100
		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
  4101
			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
  4102
			   !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
  4103
				break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4104
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4105
		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
  4106
			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
  4107
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4108
		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
  4109
			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
  4110
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4111
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4112
	}
2421
bc2d4bf9cbe5 Removed trailing spaces.
Florian Pose <fp@igh-essen.com>
parents: 2050
diff changeset
  4113
1360
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4114
	return IRQ_HANDLED;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4117
#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
  4118
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4119
 * 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
  4120
 * @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
  4121
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4122
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4123
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4124
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
  4125
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4126
	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
  4127
	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
  4128
	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
  4129
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4130
	/* 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
  4131
	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
  4132
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4133
	/* 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
  4134
	 * 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
  4135
	 * 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
  4136
	 * 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
  4137
	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
  4138
		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
  4139
						&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
  4140
		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
  4141
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4142
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4143
	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
  4144
	                  &work_done, budget);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4145
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4146
	if (tx_cleaned)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4147
		work_done = budget;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4148
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4149
	/* 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
  4150
	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
  4151
		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
  4152
			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
  4153
		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
  4154
		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
  4155
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4156
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4157
	return work_done;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4160
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4161
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4162
 * 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
  4163
 * @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
  4164
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4165
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4166
static bool
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4167
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
  4168
                   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
  4169
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4170
	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
  4171
	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
  4172
	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
  4173
	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
  4174
#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
  4175
	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
  4176
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4177
	bool cleaned = false;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4178
	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
  4179
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4180
	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
  4181
	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
  4182
	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
  4183
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4184
	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
  4185
		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
  4186
			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
  4187
			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
  4188
			cleaned = (i == eop);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4189
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4190
			if (cleaned) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4191
				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
  4192
				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
  4193
				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
  4194
				/* 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
  4195
				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
  4196
				            skb->len;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4197
				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
  4198
				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
  4199
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4200
			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
  4201
			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
  4202
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4203
			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
  4204
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4205
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4206
		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
  4207
		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
  4208
#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
  4209
#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
  4210
		/* 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
  4211
		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
  4212
#endif
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4215
	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
  4216
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4217
#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
  4218
	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
  4219
		     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
  4220
		/* 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
  4221
		 * 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
  4222
		 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4223
		smp_mb();
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4224
		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
  4225
			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
  4226
			++adapter->restart_queue;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4230
	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
  4231
		/* 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
  4232
		 * 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
  4233
		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
  4234
		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
  4235
		    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
  4236
		               (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
  4237
		    && !(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
  4238
		         E1000_STATUS_TXOFF)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4239
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4240
			/* 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
  4241
			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
  4242
					"  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
  4243
					"  TDH                  <%x>\n"
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4244
					"  TDT                  <%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_use          <%x>\n"
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4246
					"  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
  4247
					"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
  4248
					"  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
  4249
					"  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
  4250
					"  jiffies              <%lx>\n"
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4251
					"  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
  4252
				(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
  4253
					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
  4254
				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
  4255
				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
  4256
				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
  4257
				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
  4258
				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
  4259
				eop,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4260
				jiffies,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4261
				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
  4262
			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
  4263
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4264
	}
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_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
  4266
	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
  4267
	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
  4268
	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
  4269
	return cleaned;
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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4273
 * 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
  4274
 * @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
  4275
 * @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
  4276
 * @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
  4277
 * @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
  4278
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4279
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4280
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4281
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
  4282
		  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
  4283
		  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
  4284
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4285
	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
  4286
	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
  4287
	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
  4288
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4289
	/* 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
  4290
	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
  4291
	/* 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
  4292
	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
  4293
	/* 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
  4294
	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
  4295
		/* 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
  4296
		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
  4297
		return;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4298
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4299
	/* 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
  4300
	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
  4301
		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
  4302
			return;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4303
	} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4304
		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
  4305
			return;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4306
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4307
	/* 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
  4308
	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
  4309
		/* 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
  4310
		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
  4311
	} 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
  4312
		/* 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
  4313
		/* 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
  4314
		 * 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
  4315
		 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4316
		__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
  4317
		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
  4318
		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
  4319
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4320
	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
  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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4324
 * 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
  4325
 * @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
  4326
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4327
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4328
static bool
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4329
#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
  4330
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
  4331
                   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
  4332
                   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
  4333
#else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4334
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
  4335
                   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
  4336
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4337
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4338
	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
  4339
	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
  4340
	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
  4341
	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
  4342
	unsigned long flags;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4343
	u32 length;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4344
	u8 last_byte;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4345
	unsigned int i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4346
	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
  4347
	bool cleaned = false;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4348
	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
  4349
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4350
	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
  4351
	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
  4352
	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
  4353
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4354
	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
  4355
		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
  4356
		u8 status;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4357
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4358
#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
  4359
		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
  4360
			break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4361
		(*work_done)++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4362
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4363
		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
  4364
		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
  4365
		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
  4366
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4367
		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
  4368
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4369
		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
  4370
		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
  4371
		prefetch(next_rxd);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4372
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4373
		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
  4374
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4375
		cleaned = true;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4376
		cleaned_count++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4377
		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
  4378
		                 buffer_info->dma,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4379
		                 buffer_info->length,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4380
		                 PCI_DMA_FROMDEVICE);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4381
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4382
		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
  4383
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4384
		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
  4385
			/* 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
  4386
			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
  4387
				  " 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
  4388
			/* recycle */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4389
			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
  4390
			goto next_desc;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4393
		if (!adapter->ecdev &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4394
                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
  4395
			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
  4396
			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
  4397
			              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
  4398
				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
  4399
				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
  4400
				                       &adapter->stats,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4401
				                       length, skb->data);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4402
				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
  4403
				                       flags);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4404
				length--;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4405
			} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4406
				/* recycle */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4407
				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
  4408
				goto next_desc;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4412
		/* 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
  4413
		 * 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
  4414
		length -= 4;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4415
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4416
		/* 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
  4417
		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
  4418
		total_rx_packets++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4419
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4420
		/* 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
  4421
		 * 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
  4422
		 * 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
  4423
		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
  4424
			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
  4425
			    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
  4426
			if (new_skb) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4427
				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
  4428
				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
  4429
							       -NET_IP_ALIGN,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4430
							       (skb->data -
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4431
							        NET_IP_ALIGN),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4432
							       (length +
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4433
							        NET_IP_ALIGN));
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4434
				/* 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
  4435
				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
  4436
				skb = new_skb;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4437
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4438
			/* 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
  4439
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4440
		/* end copybreak code */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4441
		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
  4442
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4443
		/* Receive Checksum Offload */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4444
		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
  4445
				  (u32)(status) |
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4446
				  ((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
  4447
				  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
  4448
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4449
		if (adapter->ecdev) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4450
			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
  4451
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4452
			// 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
  4453
			// 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
  4454
			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
  4455
		} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4456
			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
  4457
#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
  4458
			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
  4459
			   	 (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
  4460
				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
  4461
							 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
  4462
							 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
  4463
			} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4464
				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
  4465
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4466
#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
  4467
			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
  4468
				    (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
  4469
				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
  4470
						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
  4471
						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
  4472
			} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4473
				netif_rx(skb);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4474
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4475
#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
  4476
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4477
		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
  4478
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4479
next_desc:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4480
		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
  4481
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4482
		/* 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
  4483
		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
  4484
			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
  4485
			cleaned_count = 0;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4488
		/* use prefetched values */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4489
		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
  4490
		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
  4491
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4492
	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
  4493
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4494
	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
  4495
	if (cleaned_count)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4496
		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
  4497
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_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
  4499
	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
  4500
	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
  4501
	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
  4502
	return cleaned;
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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4506
 * 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
  4507
 * @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
  4508
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4509
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4510
static bool
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4511
#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
  4512
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
  4513
                      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
  4514
                      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
  4515
#else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4516
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
  4517
                      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
  4518
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4519
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4520
	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
  4521
	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
  4522
	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
  4523
	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
  4524
	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
  4525
	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
  4526
	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
  4527
	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
  4528
	u32 length, staterr;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4529
	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
  4530
	bool cleaned = false;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4531
	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
  4532
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4533
	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
  4534
	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
  4535
	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
  4536
	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
  4537
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4538
	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
  4539
		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
  4540
		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
  4541
#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
  4542
		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
  4543
			break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4544
		(*work_done)++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4545
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4546
		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
  4547
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4548
		/* 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
  4549
		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
  4550
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4551
		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
  4552
		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
  4553
		prefetch(next_rxd);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4554
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4555
		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
  4556
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4557
		cleaned = true;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4558
		cleaned_count++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4559
		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
  4560
				 buffer_info->length,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4561
				 PCI_DMA_FROMDEVICE);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4562
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4563
		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
  4564
			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
  4565
				  " 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
  4566
			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
  4567
			goto next_desc;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4570
		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
  4571
			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
  4572
			goto next_desc;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4575
		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
  4576
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4577
		if (unlikely(!length)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4578
			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
  4579
				  " 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
  4580
			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
  4581
			goto next_desc;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4584
		/* Good Receive */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4585
		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
  4586
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4587
		{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4588
		/* 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
  4589
		   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
  4590
		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
  4591
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4592
		/* 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
  4593
		 * 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
  4594
		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
  4595
			u8 *vaddr;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4596
			/* 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
  4597
			 * 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
  4598
			 * very long */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4599
			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
  4600
				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
  4601
				PAGE_SIZE,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4602
				PCI_DMA_FROMDEVICE);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4603
			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
  4604
			                    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
  4605
			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
  4606
			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
  4607
			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
  4608
				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
  4609
				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
  4610
			/* remove the CRC */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4611
			l1 -= 4;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4612
			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
  4613
			goto copydone;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4614
		} /* if */
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4617
		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
  4618
			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
  4619
				break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4620
			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
  4621
					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
  4622
			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
  4623
			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
  4624
			                   length);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4625
			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
  4626
			skb->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->data_len += length;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4628
			skb->truesize += length;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4631
		/* 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
  4632
		 * 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
  4633
		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
  4634
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4635
copydone:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4636
		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
  4637
		total_rx_packets++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4638
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4639
		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
  4640
				  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
  4641
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4642
		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
  4643
			   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
  4644
			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
  4645
		if (adapter->ecdev) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4646
			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
  4647
		} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4648
			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
  4649
#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
  4650
			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
  4651
				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
  4652
					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
  4653
					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
  4654
			} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4655
				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
  4656
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4657
#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
  4658
			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
  4659
				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
  4660
					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
  4661
					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
  4662
			} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4663
				netif_rx(skb);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4664
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4665
#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
  4666
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4667
		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
  4668
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4669
next_desc:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4670
		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
  4671
		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
  4672
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4673
		/* 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
  4674
		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
  4675
			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
  4676
			cleaned_count = 0;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4679
		/* use prefetched values */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4680
		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
  4681
		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
  4682
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4683
		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
  4684
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4685
	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
  4686
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4687
	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
  4688
	if (cleaned_count)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4689
		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
  4690
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_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
  4692
	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
  4693
	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
  4694
	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
  4695
	return cleaned;
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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4699
 * 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
  4700
 * @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
  4701
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4702
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4703
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4704
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
  4705
                       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
  4706
		       int cleaned_count)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4707
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4708
	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
  4709
	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
  4710
	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
  4711
	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
  4712
	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
  4713
	unsigned int i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4714
	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
  4715
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4716
	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
  4717
	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
  4718
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4719
	while (cleaned_count--) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4720
		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
  4721
		if (skb) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4722
			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
  4723
			goto map_skb;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4726
		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
  4727
		if (unlikely(!skb)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4728
			/* 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
  4729
			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
  4730
			break;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4733
		/* 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
  4734
		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
  4735
			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
  4736
			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
  4737
					     "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
  4738
			/* 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
  4739
			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
  4740
			/* 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
  4741
			if (!skb) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4742
				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
  4743
				break;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4746
			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
  4747
				/* give up */
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(skb);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4749
				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
  4750
				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
  4751
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4752
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4753
			/* Use new allocation */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4754
			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
  4755
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4756
		/* 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
  4757
		 * 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
  4758
		 * 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
  4759
		 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4760
		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
  4761
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4762
		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
  4763
		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
  4764
map_skb:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4765
		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
  4766
						  skb->data,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4767
						  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
  4768
						  PCI_DMA_FROMDEVICE);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4769
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4770
		/* 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
  4771
		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
  4772
					(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
  4773
					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
  4774
			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
  4775
				"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
  4776
				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
  4777
				(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
  4778
			if (!adapter->ecdev) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4779
				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
  4780
				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
  4781
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4782
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4783
			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
  4784
					 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
  4785
					 PCI_DMA_FROMDEVICE);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4786
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4787
			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
  4788
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4789
		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
  4790
		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
  4791
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4792
		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
  4793
			i = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4794
		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
  4795
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4796
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4797
	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
  4798
		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
  4799
		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
  4800
			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
  4801
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4802
		/* 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
  4803
		 * 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
  4804
		 * 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
  4805
		 * 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
  4806
		wmb();
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4807
		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
  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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4812
 * 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
  4813
 * @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
  4814
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4815
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4816
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4817
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
  4818
                          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
  4819
			  int cleaned_count)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4820
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4821
	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
  4822
	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
  4823
	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
  4824
	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
  4825
	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
  4826
	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
  4827
	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
  4828
	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
  4829
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4830
	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
  4831
	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
  4832
	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
  4833
	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
  4834
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4835
	while (cleaned_count--) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4836
		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
  4837
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4838
		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
  4839
			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
  4840
				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
  4841
					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
  4842
						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
  4843
					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
  4844
						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
  4845
						goto no_buffers;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4846
					}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4847
					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
  4848
						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
  4849
							    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
  4850
							    0, PAGE_SIZE,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4851
							    PCI_DMA_FROMDEVICE);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4852
				}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4853
				/* 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
  4854
				 * 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
  4855
				 * this info.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4856
				 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4857
				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
  4858
				     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
  4859
			} else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4860
				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
  4861
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4862
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4863
		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
  4864
		                       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
  4865
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4866
		if (unlikely(!skb)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4867
			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
  4868
			break;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4871
		/* 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
  4872
		 * 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
  4873
		 * 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
  4874
		 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4875
		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
  4876
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4877
		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
  4878
		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
  4879
		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
  4880
						  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
  4881
						  PCI_DMA_FROMDEVICE);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4882
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4883
		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
  4884
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4885
		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
  4886
		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
  4887
		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
  4888
		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
  4889
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4890
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4891
no_buffers:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4892
	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
  4893
		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
  4894
		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
  4895
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4896
		/* 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
  4897
		 * 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
  4898
		 * 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
  4899
		 * 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
  4900
		wmb();
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4901
		/* 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
  4902
		 * 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
  4903
		 * twice as much.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4904
		 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4905
		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
  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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4910
 * 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
  4911
 * @adapter:
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4914
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4915
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
  4916
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4917
	u16 phy_status;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4918
	u16 phy_ctrl;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4919
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4920
	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
  4921
	   !(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
  4922
		return;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4923
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4924
	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
  4925
		/* 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
  4926
		 * 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
  4927
		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
  4928
		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
  4929
		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
  4930
		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
  4931
		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
  4932
		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
  4933
			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
  4934
			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
  4935
					    phy_ctrl);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4936
			adapter->smartspeed++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4937
			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
  4938
			   !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
  4939
				   	       &phy_ctrl)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4940
				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
  4941
					     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
  4942
				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
  4943
						    phy_ctrl);
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
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4946
		return;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4947
	} 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
  4948
		/* 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
  4949
		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
  4950
		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
  4951
		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
  4952
		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
  4953
		   !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
  4954
			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
  4955
				     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
  4956
			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
  4957
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4958
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4959
	/* 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
  4960
	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
  4961
		adapter->smartspeed = 0;
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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4965
 * e1000_ioctl -
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4966
 * @netdev:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4967
 * @ifreq:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4968
 * @cmd:
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4971
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4972
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
  4973
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4974
	switch (cmd) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4975
	case SIOCGMIIPHY:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4976
	case SIOCGMIIREG:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4977
	case SIOCSMIIREG:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4978
		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
  4979
	default:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4980
		return -EOPNOTSUPP;
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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4985
 * e1000_mii_ioctl -
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4986
 * @netdev:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4987
 * @ifreq:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4988
 * @cmd:
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4991
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4992
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
  4993
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4994
	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
  4995
	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
  4996
	int retval;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4997
	u16 mii_reg;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4998
	u16 spddplx;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4999
	unsigned long flags;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5000
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5001
	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
  5002
		return -EOPNOTSUPP;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5003
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5004
	switch (cmd) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5005
	case SIOCGMIIPHY:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5006
		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
  5007
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5008
	case SIOCGMIIREG:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5009
		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
  5010
			return -EPERM;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5011
		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
  5012
		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
  5013
				   &data->val_out)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5014
			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
  5015
			return -EIO;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5016
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5017
		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
  5018
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5019
	case SIOCSMIIREG:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5020
		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
  5021
			return -EPERM;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5022
		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
  5023
			return -EFAULT;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5024
		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
  5025
		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
  5026
		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
  5027
					mii_reg)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5028
			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
  5029
			return -EIO;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5030
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5031
		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
  5032
		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
  5033
			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
  5034
			case PHY_CTRL:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5035
				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
  5036
					break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5037
				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
  5038
					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
  5039
					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
  5040
				} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5041
					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
  5042
						spddplx = SPEED_1000;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5043
					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
  5044
						spddplx = SPEED_100;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5045
					else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5046
						spddplx = SPEED_10;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5047
					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
  5048
						   ? DUPLEX_FULL :
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5049
						   DUPLEX_HALF;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5050
					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
  5051
								    spddplx);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5052
					if (retval)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5053
						return retval;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5054
				}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5055
				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
  5056
					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
  5057
				else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5058
					e1000_reset(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5059
				break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5060
			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
  5061
			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
  5062
				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
  5063
					return -EIO;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5064
				break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5065
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5066
		} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5067
			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
  5068
			case PHY_CTRL:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5069
				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
  5070
					break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5071
				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
  5072
					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
  5073
				else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5074
					e1000_reset(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5075
				break;
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
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5078
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5079
	default:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5080
		return -EOPNOTSUPP;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5081
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5082
	return E1000_SUCCESS;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5085
void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5086
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
  5087
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5088
	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
  5089
	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
  5090
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5091
	if (ret_val)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5092
		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
  5093
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5094
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5095
void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5096
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
  5097
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5098
	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
  5099
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5100
	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
  5101
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5102
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5103
int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5104
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
  5105
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5106
	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
  5107
	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
  5108
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5109
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5110
void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5111
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
  5112
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5113
	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
  5114
	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
  5115
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5116
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5117
s32
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5118
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
  5119
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5120
    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
  5121
    u16 cap_offset;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5122
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5123
    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
  5124
    if (!cap_offset)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5125
        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
  5126
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5127
    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
  5128
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5129
    return E1000_SUCCESS;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5132
void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5133
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
  5134
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5135
	outl(value, port);
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5138
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5139
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
  5140
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5141
	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
  5142
	u32 ctrl, rctl;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5143
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5144
	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
  5145
		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
  5146
	adapter->vlgrp = grp;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5147
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5148
	if (grp) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5149
		/* 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
  5150
		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
  5151
		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
  5152
		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
  5153
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5154
		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
  5155
			/* 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
  5156
			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
  5157
			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
  5158
			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
  5159
			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
  5160
			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
  5161
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5162
	} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5163
		/* 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
  5164
		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
  5165
		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
  5166
		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
  5167
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5168
		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
  5169
			/* disable VLAN filtering */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5170
			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
  5171
			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
  5172
			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
  5173
			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
  5174
			    (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
  5175
				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
  5176
				                       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
  5177
				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
  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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5182
	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
  5183
		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
  5184
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5185
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5186
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5187
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
  5188
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5189
	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
  5190
	u32 vfta, index;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5191
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5192
	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
  5193
	     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
  5194
	    (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
  5195
		return;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5196
	/* 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
  5197
	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
  5198
	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
  5199
	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
  5200
	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
  5201
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5202
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5203
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5204
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
  5205
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5206
	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
  5207
	u32 vfta, index;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5208
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5209
	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
  5210
		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
  5211
	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
  5212
	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
  5213
		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
  5214
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5215
	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
  5216
	     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
  5217
	    (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
  5218
		/* 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
  5219
		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
  5220
		return;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5223
	/* 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
  5224
	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
  5225
	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
  5226
	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
  5227
	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
  5228
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5229
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5230
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5231
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
  5232
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5233
	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
  5234
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5235
	if (adapter->vlgrp) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5236
		u16 vid;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5237
		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
  5238
			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
  5239
				continue;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5240
			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
  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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5245
int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5246
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
  5247
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5248
	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
  5249
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5250
	/* 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
  5251
	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
  5252
		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
  5253
		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
  5254
		return -EINVAL;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5257
	switch (spddplx) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5258
	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
  5259
		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
  5260
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5261
	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
  5262
		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
  5263
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5264
	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
  5265
		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
  5266
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5267
	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
  5268
		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
  5269
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5270
	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
  5271
		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
  5272
		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
  5273
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5274
	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
  5275
	default:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5276
		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
  5277
		return -EINVAL;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5278
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5279
	return 0;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5282
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5283
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
  5284
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5285
	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
  5286
	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
  5287
	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
  5288
	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
  5289
#ifdef CONFIG_PM
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5290
	int retval = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5291
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5292
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5293
	if (adapter->ecdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5294
		return -EBUSY;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5295
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5296
	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
  5297
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5298
	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
  5299
		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
  5300
		e1000_down(adapter);
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5303
#ifdef CONFIG_PM
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5304
	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
  5305
	if (retval)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5306
		return retval;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5307
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5308
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5309
	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
  5310
	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
  5311
		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
  5312
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5313
	if (wufc) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5314
		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
  5315
		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
  5316
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5317
		/* 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
  5318
		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
  5319
			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
  5320
			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
  5321
			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
  5322
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5323
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5324
		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
  5325
			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
  5326
			/* 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
  5327
			#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
  5328
			/* 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
  5329
			#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
  5330
			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
  5331
				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
  5332
			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
  5333
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5334
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5335
		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
  5336
		   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
  5337
			/* 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
  5338
			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
  5339
			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
  5340
			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
  5341
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5342
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5343
		/* 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
  5344
		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
  5345
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, 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
  5347
		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
  5348
		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
  5349
		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
  5350
	} else {
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, WUC, 0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5352
		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
  5353
		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
  5354
		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
  5355
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5356
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5357
	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
  5358
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5359
	/* 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
  5360
	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
  5361
		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
  5362
		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
  5363
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5364
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5365
	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
  5366
		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
  5367
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5368
	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
  5369
		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
  5370
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5371
	/* 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
  5372
	 * 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
  5373
	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
  5374
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5375
	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
  5376
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5377
	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
  5378
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5379
	return 0;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5382
#ifdef CONFIG_PM
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5383
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5384
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
  5385
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5386
	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
  5387
	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
  5388
	u32 err;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5389
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5390
	if (adapter->ecdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5391
		return -EBUSY;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5392
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5393
	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
  5394
	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
  5395
	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
  5396
		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
  5397
		return err;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5398
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5399
	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
  5400
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_D3hot, 0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5402
	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
  5403
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5404
	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
  5405
		return err;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5406
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5407
	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
  5408
	e1000_reset(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5409
	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
  5410
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5411
	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
  5412
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5413
	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
  5414
		e1000_up(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5415
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5416
	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
  5417
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5418
	/* 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
  5419
	 * 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
  5420
	 * 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
  5421
	 * of the driver. */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5422
	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
  5423
	    !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
  5424
		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
  5425
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5426
	return 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5427
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5428
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5429
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5430
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
  5431
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5432
	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
  5433
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5434
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5435
#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
  5436
/*
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5437
 * 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
  5438
 * 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
  5439
 * 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
  5440
 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5441
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5442
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
  5443
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5444
	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
  5445
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5446
	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
  5447
	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
  5448
	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
  5449
#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
  5450
	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
  5451
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5452
	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
  5453
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5454
#endif
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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5457
 * 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
  5458
 * @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
  5459
 * @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
  5460
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5461
 * 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
  5462
 * 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
  5463
 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5464
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
  5465
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5466
	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
  5467
	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
  5468
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5469
	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
  5470
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5471
	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
  5472
		e1000_down(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5473
	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
  5474
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5475
	/* 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
  5476
	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
  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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5480
 * 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
  5481
 * @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
  5482
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5483
 * 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
  5484
 * 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
  5485
 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5486
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
  5487
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5488
	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
  5489
	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
  5490
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5491
	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
  5492
		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
  5493
		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
  5494
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5495
	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
  5496
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_D3hot, 0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5498
	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
  5499
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5500
	e1000_reset(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5501
	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
  5502
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5503
	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
  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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5507
 * 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
  5508
 * @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
  5509
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5510
 * 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
  5511
 * 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
  5512
 * 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
  5513
 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5514
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
  5515
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5516
	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
  5517
	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
  5518
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5519
	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
  5520
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5521
	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
  5522
		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
  5523
			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
  5524
			return;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5528
	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
  5529
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5530
	/* 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
  5531
	 * 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
  5532
	 * 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
  5533
	 * of the driver. */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5534
	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
  5535
	    !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
  5536
		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
  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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5540
/* e1000_main.c */