devices/e1000/e1000_main-2.6.26-ethercat.c
author Andreas Stewering-Bone <ab@igh-essen.com>
Wed, 16 Mar 2011 22:12:23 +0100
changeset 2054 3417bbc4ad2f
parent 2050 a3e59f2a8589
child 2421 bc2d4bf9cbe5
child 2589 2b9c78543663
permissions -rw-r--r--
First working RTDM Version,
to be reviewed,
further testing and optimation needed

Thanks to Moehwald GmbH B.Benner for Basic Code
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;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   675
	
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   676
	if (!adapter->ecdev) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   677
		netif_carrier_off(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   678
		netif_stop_queue(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   679
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   680
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   681
	e1000_reset(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   682
	e1000_clean_all_tx_rings(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   683
	e1000_clean_all_rx_rings(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   684
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   685
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   686
void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   687
e1000_reinit_locked(struct e1000_adapter *adapter)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   688
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   689
	WARN_ON(in_interrupt());
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   690
	while (test_and_set_bit(__E1000_RESETTING, &adapter->flags))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   691
		msleep(1);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   692
	e1000_down(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   693
	e1000_up(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   694
	clear_bit(__E1000_RESETTING, &adapter->flags);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   695
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   696
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   697
void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   698
e1000_reset(struct e1000_adapter *adapter)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   699
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   700
	u32 pba = 0, tx_space, min_tx_space, min_rx_space;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   701
	u16 fc_high_water_mark = E1000_FC_HIGH_DIFF;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   702
	bool legacy_pba_adjust = false;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   703
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   704
	/* Repartition Pba for greater than 9k mtu
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   705
	 * To take effect CTRL.RST is required.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   706
	 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   707
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   708
	switch (adapter->hw.mac_type) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   709
	case e1000_82542_rev2_0:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   710
	case e1000_82542_rev2_1:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   711
	case e1000_82543:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   712
	case e1000_82544:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   713
	case e1000_82540:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   714
	case e1000_82541:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   715
	case e1000_82541_rev_2:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   716
		legacy_pba_adjust = true;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   717
		pba = E1000_PBA_48K;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   718
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   719
	case e1000_82545:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   720
	case e1000_82545_rev_3:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   721
	case e1000_82546:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   722
	case e1000_82546_rev_3:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   723
		pba = E1000_PBA_48K;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   724
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   725
	case e1000_82547:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   726
	case e1000_82547_rev_2:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   727
		legacy_pba_adjust = true;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   728
		pba = E1000_PBA_30K;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   729
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   730
	case e1000_82571:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   731
	case e1000_82572:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   732
	case e1000_80003es2lan:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   733
		pba = E1000_PBA_38K;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   734
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   735
	case e1000_82573:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   736
		pba = E1000_PBA_20K;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   737
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   738
	case e1000_ich8lan:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   739
		pba = E1000_PBA_8K;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   740
	case e1000_undefined:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   741
	case e1000_num_macs:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   742
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   743
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   744
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   745
	if (legacy_pba_adjust) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   746
		if (adapter->netdev->mtu > E1000_RXBUFFER_8192)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   747
			pba -= 8; /* allocate more FIFO for Tx */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   748
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   749
		if (adapter->hw.mac_type == e1000_82547) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   750
			adapter->tx_fifo_head = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   751
			adapter->tx_head_addr = pba << E1000_TX_HEAD_ADDR_SHIFT;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   752
			adapter->tx_fifo_size =
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   753
				(E1000_PBA_40K - pba) << E1000_PBA_BYTES_SHIFT;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   754
			atomic_set(&adapter->tx_fifo_stall, 0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   755
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   756
	} else if (adapter->hw.max_frame_size > MAXIMUM_ETHERNET_FRAME_SIZE) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   757
		/* adjust PBA for jumbo frames */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   758
		E1000_WRITE_REG(&adapter->hw, PBA, pba);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   759
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   760
		/* To maintain wire speed transmits, the Tx FIFO should be
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   761
		 * large enough to accomodate two full transmit packets,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   762
		 * rounded up to the next 1KB and expressed in KB.  Likewise,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   763
		 * the Rx FIFO should be large enough to accomodate at least
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   764
		 * one full receive packet and is similarly rounded up and
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   765
		 * expressed in KB. */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   766
		pba = E1000_READ_REG(&adapter->hw, PBA);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   767
		/* upper 16 bits has Tx packet buffer allocation size in KB */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   768
		tx_space = pba >> 16;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   769
		/* lower 16 bits has Rx packet buffer allocation size in KB */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   770
		pba &= 0xffff;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   771
		/* don't include ethernet FCS because hardware appends/strips */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   772
		min_rx_space = adapter->netdev->mtu + ENET_HEADER_SIZE +
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   773
		               VLAN_TAG_SIZE;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   774
		min_tx_space = min_rx_space;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   775
		min_tx_space *= 2;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   776
		min_tx_space = ALIGN(min_tx_space, 1024);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   777
		min_tx_space >>= 10;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   778
		min_rx_space = ALIGN(min_rx_space, 1024);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   779
		min_rx_space >>= 10;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   780
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   781
		/* If current Tx allocation is less than the min Tx FIFO size,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   782
		 * and the min Tx FIFO size is less than the current Rx FIFO
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   783
		 * allocation, take space away from current Rx allocation */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   784
		if (tx_space < min_tx_space &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   785
		    ((min_tx_space - tx_space) < pba)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   786
			pba = pba - (min_tx_space - tx_space);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   787
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   788
			/* PCI/PCIx hardware has PBA alignment constraints */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   789
			switch (adapter->hw.mac_type) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   790
			case e1000_82545 ... e1000_82546_rev_3:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   791
				pba &= ~(E1000_PBA_8K - 1);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   792
				break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   793
			default:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   794
				break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   795
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   796
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   797
			/* if short on rx space, rx wins and must trump tx
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   798
			 * adjustment or use Early Receive if available */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   799
			if (pba < min_rx_space) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   800
				switch (adapter->hw.mac_type) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   801
				case e1000_82573:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   802
					/* ERT enabled in e1000_configure_rx */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   803
					break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   804
				default:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   805
					pba = min_rx_space;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   806
					break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   807
				}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   808
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   809
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   810
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   811
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   812
	E1000_WRITE_REG(&adapter->hw, PBA, pba);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   813
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   814
	/* flow control settings */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   815
	/* Set the FC high water mark to 90% of the FIFO size.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   816
	 * Required to clear last 3 LSB */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   817
	fc_high_water_mark = ((pba * 9216)/10) & 0xFFF8;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   818
	/* We can't use 90% on small FIFOs because the remainder
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   819
	 * would be less than 1 full frame.  In this case, we size
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   820
	 * it to allow at least a full frame above the high water
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   821
	 *  mark. */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   822
	if (pba < E1000_PBA_16K)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   823
		fc_high_water_mark = (pba * 1024) - 1600;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   824
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   825
	adapter->hw.fc_high_water = fc_high_water_mark;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   826
	adapter->hw.fc_low_water = fc_high_water_mark - 8;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   827
	if (adapter->hw.mac_type == e1000_80003es2lan)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   828
		adapter->hw.fc_pause_time = 0xFFFF;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   829
	else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   830
		adapter->hw.fc_pause_time = E1000_FC_PAUSE_TIME;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   831
	adapter->hw.fc_send_xon = 1;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   832
	adapter->hw.fc = adapter->hw.original_fc;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   833
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   834
	/* Allow time for pending master requests to run */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   835
	e1000_reset_hw(&adapter->hw);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   836
	if (adapter->hw.mac_type >= e1000_82544)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   837
		E1000_WRITE_REG(&adapter->hw, WUC, 0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   838
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   839
	if (e1000_init_hw(&adapter->hw))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   840
		DPRINTK(PROBE, ERR, "Hardware Error\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   841
	e1000_update_mng_vlan(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   842
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   843
	/* if (adapter->hwflags & HWFLAGS_PHY_PWR_BIT) { */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   844
	if (adapter->hw.mac_type >= e1000_82544 &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   845
	    adapter->hw.mac_type <= e1000_82547_rev_2 &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   846
	    adapter->hw.autoneg == 1 &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   847
	    adapter->hw.autoneg_advertised == ADVERTISE_1000_FULL) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   848
		u32 ctrl = E1000_READ_REG(&adapter->hw, CTRL);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   849
		/* clear phy power management bit if we are in gig only mode,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   850
		 * which if enabled will attempt negotiation to 100Mb, which
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   851
		 * can cause a loss of link at power off or driver unload */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   852
		ctrl &= ~E1000_CTRL_SWDPIN3;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   853
		E1000_WRITE_REG(&adapter->hw, CTRL, ctrl);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   854
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   855
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   856
	/* Enable h/w to recognize an 802.1Q VLAN Ethernet packet */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   857
	E1000_WRITE_REG(&adapter->hw, VET, ETHERNET_IEEE_VLAN_TYPE);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   858
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   859
	e1000_reset_adaptive(&adapter->hw);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   860
	e1000_phy_get_info(&adapter->hw, &adapter->phy_info);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   861
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   862
	if (!adapter->smart_power_down &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   863
	    (adapter->hw.mac_type == e1000_82571 ||
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   864
	     adapter->hw.mac_type == e1000_82572)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   865
		u16 phy_data = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   866
		/* speed up time to link by disabling smart power down, ignore
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   867
		 * the return value of this function because there is nothing
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   868
		 * different we would do if it failed */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   869
		e1000_read_phy_reg(&adapter->hw, IGP02E1000_PHY_POWER_MGMT,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   870
		                   &phy_data);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   871
		phy_data &= ~IGP02E1000_PM_SPD;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   872
		e1000_write_phy_reg(&adapter->hw, IGP02E1000_PHY_POWER_MGMT,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   873
		                    phy_data);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   874
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   875
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   876
	e1000_release_manageability(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   877
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   878
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   879
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   880
 *  Dump the eeprom for users having checksum issues
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   881
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   882
static void e1000_dump_eeprom(struct e1000_adapter *adapter)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   883
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   884
	struct net_device *netdev = adapter->netdev;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   885
	struct ethtool_eeprom eeprom;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   886
	const struct ethtool_ops *ops = netdev->ethtool_ops;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   887
	u8 *data;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   888
	int i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   889
	u16 csum_old, csum_new = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   890
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   891
	eeprom.len = ops->get_eeprom_len(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   892
	eeprom.offset = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   893
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   894
	data = kmalloc(eeprom.len, GFP_KERNEL);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   895
	if (!data) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   896
		printk(KERN_ERR "Unable to allocate memory to dump EEPROM"
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   897
		       " data\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   898
		return;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   899
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   900
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   901
	ops->get_eeprom(netdev, &eeprom, data);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   902
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   903
	csum_old = (data[EEPROM_CHECKSUM_REG * 2]) +
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   904
		   (data[EEPROM_CHECKSUM_REG * 2 + 1] << 8);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   905
	for (i = 0; i < EEPROM_CHECKSUM_REG * 2; i += 2)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   906
		csum_new += data[i] + (data[i + 1] << 8);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   907
	csum_new = EEPROM_SUM - csum_new;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   908
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   909
	printk(KERN_ERR "/*********************/\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   910
	printk(KERN_ERR "Current EEPROM Checksum : 0x%04x\n", csum_old);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   911
	printk(KERN_ERR "Calculated              : 0x%04x\n", csum_new);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   912
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   913
	printk(KERN_ERR "Offset    Values\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   914
	printk(KERN_ERR "========  ======\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   915
	print_hex_dump(KERN_ERR, "", DUMP_PREFIX_OFFSET, 16, 1, data, 128, 0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   916
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   917
	printk(KERN_ERR "Include this output when contacting your support "
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   918
	       "provider.\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   919
	printk(KERN_ERR "This is not a software error! Something bad "
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   920
	       "happened to your hardware or\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   921
	printk(KERN_ERR "EEPROM image. Ignoring this "
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   922
	       "problem could result in further problems,\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   923
	printk(KERN_ERR "possibly loss of data, corruption or system hangs!\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   924
	printk(KERN_ERR "The MAC Address will be reset to 00:00:00:00:00:00, "
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   925
	       "which is invalid\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   926
	printk(KERN_ERR "and requires you to set the proper MAC "
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   927
	       "address manually before continuing\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   928
	printk(KERN_ERR "to enable this network device.\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   929
	printk(KERN_ERR "Please inspect the EEPROM dump and report the issue "
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   930
	       "to your hardware vendor\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   931
	printk(KERN_ERR "or Intel Customer Support: linux-nics@intel.com\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   932
	printk(KERN_ERR "/*********************/\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   933
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   934
	kfree(data);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   935
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   936
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   937
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   938
 * e1000_probe - Device Initialization Routine
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   939
 * @pdev: PCI device information struct
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   940
 * @ent: entry in e1000_pci_tbl
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   941
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   942
 * Returns 0 on success, negative on failure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   943
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   944
 * e1000_probe initializes an adapter identified by a pci_dev structure.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   945
 * The OS initialization, configuring of the adapter private structure,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   946
 * and a hardware reset occur.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   947
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   948
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   949
static int __devinit
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   950
e1000_probe(struct pci_dev *pdev,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   951
            const struct pci_device_id *ent)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   952
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   953
	struct net_device *netdev;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   954
	struct e1000_adapter *adapter;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   955
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   956
	static int cards_found = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   957
	static int global_quad_port_a = 0; /* global ksp3 port a indication */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   958
	int i, err, pci_using_dac;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   959
	u16 eeprom_data = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   960
	u16 eeprom_apme_mask = E1000_EEPROM_APME;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   961
	DECLARE_MAC_BUF(mac);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   962
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   963
	if ((err = pci_enable_device(pdev)))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   964
		return err;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   965
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   966
	if (!(err = pci_set_dma_mask(pdev, DMA_64BIT_MASK)) &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   967
	    !(err = pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK))) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   968
		pci_using_dac = 1;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   969
	} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   970
		if ((err = pci_set_dma_mask(pdev, DMA_32BIT_MASK)) &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   971
		    (err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK))) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   972
			E1000_ERR("No usable DMA configuration, aborting\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   973
			goto err_dma;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   974
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   975
		pci_using_dac = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   976
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   977
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   978
	if ((err = pci_request_regions(pdev, e1000_driver_name)))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   979
		goto err_pci_reg;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   980
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   981
	pci_set_master(pdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   982
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   983
	err = -ENOMEM;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   984
	netdev = alloc_etherdev(sizeof(struct e1000_adapter));
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   985
	if (!netdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   986
		goto err_alloc_etherdev;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   987
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   988
	SET_NETDEV_DEV(netdev, &pdev->dev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   989
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   990
	pci_set_drvdata(pdev, netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   991
	adapter = netdev_priv(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   992
	adapter->netdev = netdev;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   993
	adapter->pdev = pdev;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   994
	adapter->hw.back = adapter;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   995
	adapter->msg_enable = (1 << debug) - 1;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   996
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   997
	err = -EIO;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   998
	adapter->hw.hw_addr = ioremap(pci_resource_start(pdev, BAR_0),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   999
				      pci_resource_len(pdev, BAR_0));
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1000
	if (!adapter->hw.hw_addr)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1001
		goto err_ioremap;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1002
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1003
	for (i = BAR_1; i <= BAR_5; i++) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1004
		if (pci_resource_len(pdev, i) == 0)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1005
			continue;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1006
		if (pci_resource_flags(pdev, i) & IORESOURCE_IO) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1007
			adapter->hw.io_base = pci_resource_start(pdev, i);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1008
			break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1009
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1010
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1011
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1012
	netdev->open = &e1000_open;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1013
	netdev->stop = &e1000_close;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1014
	netdev->hard_start_xmit = &e1000_xmit_frame;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1015
	netdev->get_stats = &e1000_get_stats;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1016
	netdev->set_rx_mode = &e1000_set_rx_mode;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1017
	netdev->set_mac_address = &e1000_set_mac;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1018
	netdev->change_mtu = &e1000_change_mtu;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1019
	netdev->do_ioctl = &e1000_ioctl;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1020
	e1000_set_ethtool_ops(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1021
	netdev->tx_timeout = &e1000_tx_timeout;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1022
	netdev->watchdog_timeo = 5 * HZ;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1023
#ifdef CONFIG_E1000_NAPI
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1024
	netif_napi_add(netdev, &adapter->napi, e1000_clean, 64);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1025
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1026
	netdev->vlan_rx_register = e1000_vlan_rx_register;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1027
	netdev->vlan_rx_add_vid = e1000_vlan_rx_add_vid;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1028
	netdev->vlan_rx_kill_vid = e1000_vlan_rx_kill_vid;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1029
#ifdef CONFIG_NET_POLL_CONTROLLER
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1030
	netdev->poll_controller = e1000_netpoll;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1031
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1032
	strncpy(netdev->name, pci_name(pdev), sizeof(netdev->name) - 1);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1033
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1034
	adapter->bd_number = cards_found;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1035
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1036
	/* setup the private structure */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1037
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1038
	if ((err = e1000_sw_init(adapter)))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1039
		goto err_sw_init;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1040
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1041
	err = -EIO;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1042
	/* Flash BAR mapping must happen after e1000_sw_init
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1043
	 * because it depends on mac_type */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1044
	if ((adapter->hw.mac_type == e1000_ich8lan) &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1045
	   (pci_resource_flags(pdev, 1) & IORESOURCE_MEM)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1046
		adapter->hw.flash_address =
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1047
			ioremap(pci_resource_start(pdev, 1),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1048
				pci_resource_len(pdev, 1));
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1049
		if (!adapter->hw.flash_address)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1050
			goto err_flashmap;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1051
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1052
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1053
	if (e1000_check_phy_reset_block(&adapter->hw))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1054
		DPRINTK(PROBE, INFO, "PHY reset is blocked due to SOL/IDER session.\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1055
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1056
	if (adapter->hw.mac_type >= e1000_82543) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1057
		netdev->features = NETIF_F_SG |
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1058
				   NETIF_F_HW_CSUM |
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1059
				   NETIF_F_HW_VLAN_TX |
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1060
				   NETIF_F_HW_VLAN_RX |
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1061
				   NETIF_F_HW_VLAN_FILTER;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1062
		if (adapter->hw.mac_type == e1000_ich8lan)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1063
			netdev->features &= ~NETIF_F_HW_VLAN_FILTER;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1064
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1065
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1066
	if ((adapter->hw.mac_type >= e1000_82544) &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1067
	   (adapter->hw.mac_type != e1000_82547))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1068
		netdev->features |= NETIF_F_TSO;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1069
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1070
	if (adapter->hw.mac_type > e1000_82547_rev_2)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1071
		netdev->features |= NETIF_F_TSO6;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1072
	if (pci_using_dac)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1073
		netdev->features |= NETIF_F_HIGHDMA;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1074
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1075
	netdev->features |= NETIF_F_LLTX;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1076
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1077
	adapter->en_mng_pt = e1000_enable_mng_pass_thru(&adapter->hw);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1078
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1079
	/* initialize eeprom parameters */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1080
	if (e1000_init_eeprom_params(&adapter->hw)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1081
		E1000_ERR("EEPROM initialization failed\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1082
		goto err_eeprom;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1083
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1084
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1085
	/* before reading the EEPROM, reset the controller to
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1086
	 * put the device in a known good starting state */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1087
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1088
	e1000_reset_hw(&adapter->hw);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1089
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1090
	/* make sure the EEPROM is good */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1091
	if (e1000_validate_eeprom_checksum(&adapter->hw) < 0) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1092
		DPRINTK(PROBE, ERR, "The EEPROM Checksum Is Not Valid\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1093
		e1000_dump_eeprom(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1094
		/*
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1095
		 * set MAC address to all zeroes to invalidate and temporary
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1096
		 * disable this device for the user. This blocks regular
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1097
		 * traffic while still permitting ethtool ioctls from reaching
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1098
		 * the hardware as well as allowing the user to run the
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1099
		 * interface after manually setting a hw addr using
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1100
		 * `ip set address`
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1101
		 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1102
		memset(adapter->hw.mac_addr, 0, netdev->addr_len);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1103
	} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1104
		/* copy the MAC address out of the EEPROM */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1105
		if (e1000_read_mac_addr(&adapter->hw))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1106
			DPRINTK(PROBE, ERR, "EEPROM Read Error\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1107
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1108
	/* don't block initalization here due to bad MAC address */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1109
	memcpy(netdev->dev_addr, adapter->hw.mac_addr, netdev->addr_len);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1110
	memcpy(netdev->perm_addr, adapter->hw.mac_addr, netdev->addr_len);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1111
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1112
	if (!is_valid_ether_addr(netdev->perm_addr))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1113
		DPRINTK(PROBE, ERR, "Invalid MAC Address\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1114
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1115
	e1000_get_bus_info(&adapter->hw);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1116
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1117
	init_timer(&adapter->tx_fifo_stall_timer);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1118
	adapter->tx_fifo_stall_timer.function = &e1000_82547_tx_fifo_stall;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1119
	adapter->tx_fifo_stall_timer.data = (unsigned long) adapter;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1120
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1121
	init_timer(&adapter->watchdog_timer);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1122
	adapter->watchdog_timer.function = &e1000_watchdog;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1123
	adapter->watchdog_timer.data = (unsigned long) adapter;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1124
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1125
	init_timer(&adapter->phy_info_timer);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1126
	adapter->phy_info_timer.function = &e1000_update_phy_info;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1127
	adapter->phy_info_timer.data = (unsigned long) adapter;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1128
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1129
	INIT_WORK(&adapter->reset_task, e1000_reset_task);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1130
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1131
	e1000_check_options(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1132
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1133
	/* Initial Wake on LAN setting
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1134
	 * If APM wake is enabled in the EEPROM,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1135
	 * enable the ACPI Magic Packet filter
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1136
	 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1137
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1138
	switch (adapter->hw.mac_type) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1139
	case e1000_82542_rev2_0:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1140
	case e1000_82542_rev2_1:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1141
	case e1000_82543:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1142
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1143
	case e1000_82544:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1144
		e1000_read_eeprom(&adapter->hw,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1145
			EEPROM_INIT_CONTROL2_REG, 1, &eeprom_data);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1146
		eeprom_apme_mask = E1000_EEPROM_82544_APM;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1147
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1148
	case e1000_ich8lan:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1149
		e1000_read_eeprom(&adapter->hw,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1150
			EEPROM_INIT_CONTROL1_REG, 1, &eeprom_data);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1151
		eeprom_apme_mask = E1000_EEPROM_ICH8_APME;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1152
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1153
	case e1000_82546:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1154
	case e1000_82546_rev_3:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1155
	case e1000_82571:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1156
	case e1000_80003es2lan:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1157
		if (E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_FUNC_1){
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1158
			e1000_read_eeprom(&adapter->hw,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1159
				EEPROM_INIT_CONTROL3_PORT_B, 1, &eeprom_data);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1160
			break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1161
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1162
		/* Fall Through */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1163
	default:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1164
		e1000_read_eeprom(&adapter->hw,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1165
			EEPROM_INIT_CONTROL3_PORT_A, 1, &eeprom_data);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1166
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1167
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1168
	if (eeprom_data & eeprom_apme_mask)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1169
		adapter->eeprom_wol |= E1000_WUFC_MAG;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1170
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1171
	/* now that we have the eeprom settings, apply the special cases
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1172
	 * where the eeprom may be wrong or the board simply won't support
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1173
	 * wake on lan on a particular port */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1174
	switch (pdev->device) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1175
	case E1000_DEV_ID_82546GB_PCIE:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1176
		adapter->eeprom_wol = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1177
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1178
	case E1000_DEV_ID_82546EB_FIBER:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1179
	case E1000_DEV_ID_82546GB_FIBER:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1180
	case E1000_DEV_ID_82571EB_FIBER:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1181
		/* Wake events only supported on port A for dual fiber
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1182
		 * regardless of eeprom setting */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1183
		if (E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_FUNC_1)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1184
			adapter->eeprom_wol = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1185
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1186
	case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1187
	case E1000_DEV_ID_82571EB_QUAD_COPPER:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1188
	case E1000_DEV_ID_82571EB_QUAD_FIBER:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1189
	case E1000_DEV_ID_82571EB_QUAD_COPPER_LOWPROFILE:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1190
	case E1000_DEV_ID_82571PT_QUAD_COPPER:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1191
		/* if quad port adapter, disable WoL on all but port A */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1192
		if (global_quad_port_a != 0)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1193
			adapter->eeprom_wol = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1194
		else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1195
			adapter->quad_port_a = 1;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1196
		/* Reset for multiple quad port adapters */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1197
		if (++global_quad_port_a == 4)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1198
			global_quad_port_a = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1199
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1200
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1201
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1202
	/* initialize the wol settings based on the eeprom settings */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1203
	adapter->wol = adapter->eeprom_wol;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1204
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1205
	/* print bus type/speed/width info */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1206
	{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1207
	struct e1000_hw *hw = &adapter->hw;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1208
	DPRINTK(PROBE, INFO, "(PCI%s:%s:%s) ",
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1209
		((hw->bus_type == e1000_bus_type_pcix) ? "-X" :
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1210
		 (hw->bus_type == e1000_bus_type_pci_express ? " Express":"")),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1211
		((hw->bus_speed == e1000_bus_speed_2500) ? "2.5Gb/s" :
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1212
		 (hw->bus_speed == e1000_bus_speed_133) ? "133MHz" :
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1213
		 (hw->bus_speed == e1000_bus_speed_120) ? "120MHz" :
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1214
		 (hw->bus_speed == e1000_bus_speed_100) ? "100MHz" :
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1215
		 (hw->bus_speed == e1000_bus_speed_66) ? "66MHz" : "33MHz"),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1216
		((hw->bus_width == e1000_bus_width_64) ? "64-bit" :
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1217
		 (hw->bus_width == e1000_bus_width_pciex_4) ? "Width x4" :
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1218
		 (hw->bus_width == e1000_bus_width_pciex_1) ? "Width x1" :
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1219
		 "32-bit"));
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1220
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1221
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1222
	printk("%s\n", print_mac(mac, netdev->dev_addr));
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1223
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1224
	if (adapter->hw.bus_type == e1000_bus_type_pci_express) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1225
		DPRINTK(PROBE, WARNING, "This device (id %04x:%04x) will no "
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1226
			"longer be supported by this driver in the future.\n",
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1227
			pdev->vendor, pdev->device);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1228
		DPRINTK(PROBE, WARNING, "please use the \"e1000e\" "
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1229
			"driver instead.\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1230
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1231
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1232
	/* reset the hardware with the new settings */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1233
	e1000_reset(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1234
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1235
	/* If the controller is 82573 and f/w is AMT, do not set
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1236
	 * DRV_LOAD until the interface is up.  For all other cases,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1237
	 * let the f/w know that the h/w is now under the control
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1238
	 * of the driver. */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1239
	if (adapter->hw.mac_type != e1000_82573 ||
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1240
	    !e1000_check_mng_mode(&adapter->hw))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1241
		e1000_get_hw_control(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1242
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1243
	// offer device to EtherCAT master module
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1244
	adapter->ecdev = ecdev_offer(netdev, ec_poll, THIS_MODULE);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1245
	if (adapter->ecdev) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1246
		if (ecdev_open(adapter->ecdev)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1247
			ecdev_withdraw(adapter->ecdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1248
			goto err_register;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1249
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1250
	} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1251
		/* tell the stack to leave us alone until e1000_open() is called */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1252
		netif_carrier_off(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1253
		netif_stop_queue(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1254
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1255
		strcpy(netdev->name, "eth%d");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1256
		if ((err = register_netdev(netdev)))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1257
			goto err_register;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1258
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1259
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1260
	DPRINTK(PROBE, INFO, "Intel(R) PRO/1000 Network Connection\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1261
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1262
	cards_found++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1263
	return 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1264
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1265
err_register:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1266
	e1000_release_hw_control(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1267
err_eeprom:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1268
	if (!e1000_check_phy_reset_block(&adapter->hw))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1269
		e1000_phy_hw_reset(&adapter->hw);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1270
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1271
	if (adapter->hw.flash_address)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1272
		iounmap(adapter->hw.flash_address);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1273
err_flashmap:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1274
#ifdef CONFIG_E1000_NAPI
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1275
	for (i = 0; i < adapter->num_rx_queues; i++)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1276
		dev_put(&adapter->polling_netdev[i]);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1277
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1278
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1279
	kfree(adapter->tx_ring);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1280
	kfree(adapter->rx_ring);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1281
#ifdef CONFIG_E1000_NAPI
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1282
	kfree(adapter->polling_netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1283
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1284
err_sw_init:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1285
	iounmap(adapter->hw.hw_addr);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1286
err_ioremap:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1287
	free_netdev(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1288
err_alloc_etherdev:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1289
	pci_release_regions(pdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1290
err_pci_reg:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1291
err_dma:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1292
	pci_disable_device(pdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1293
	return err;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1294
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1295
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1296
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1297
 * e1000_remove - Device Removal Routine
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1298
 * @pdev: PCI device information struct
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1299
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1300
 * e1000_remove is called by the PCI subsystem to alert the driver
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1301
 * that it should release a PCI device.  The could be caused by a
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1302
 * Hot-Plug event, or because the driver is going to be removed from
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1303
 * memory.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1304
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1305
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1306
static void __devexit
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1307
e1000_remove(struct pci_dev *pdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1308
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1309
	struct net_device *netdev = pci_get_drvdata(pdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1310
	struct e1000_adapter *adapter = netdev_priv(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1311
#ifdef CONFIG_E1000_NAPI
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1312
	int i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1313
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1314
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1315
	cancel_work_sync(&adapter->reset_task);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1316
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1317
	e1000_release_manageability(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1318
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1319
	/* Release control of h/w to f/w.  If f/w is AMT enabled, this
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1320
	 * would have already happened in close and is redundant. */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1321
	e1000_release_hw_control(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1322
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1323
#ifdef CONFIG_E1000_NAPI
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1324
	for (i = 0; i < adapter->num_rx_queues; i++)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1325
		dev_put(&adapter->polling_netdev[i]);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1326
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1327
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1328
	if (adapter->ecdev) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1329
		ecdev_close(adapter->ecdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1330
		ecdev_withdraw(adapter->ecdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1331
	} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1332
		unregister_netdev(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1333
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1334
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1335
	if (!e1000_check_phy_reset_block(&adapter->hw))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1336
		e1000_phy_hw_reset(&adapter->hw);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1337
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1338
	kfree(adapter->tx_ring);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1339
	kfree(adapter->rx_ring);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1340
#ifdef CONFIG_E1000_NAPI
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1341
	kfree(adapter->polling_netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1342
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1343
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1344
	iounmap(adapter->hw.hw_addr);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1345
	if (adapter->hw.flash_address)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1346
		iounmap(adapter->hw.flash_address);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1347
	pci_release_regions(pdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1348
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1349
	free_netdev(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1350
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1351
	pci_disable_device(pdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1352
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1353
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1354
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1355
 * e1000_sw_init - Initialize general software structures (struct e1000_adapter)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1356
 * @adapter: board private structure to initialize
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1357
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1358
 * e1000_sw_init initializes the Adapter private data structure.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1359
 * Fields are initialized based on PCI device information and
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1360
 * OS network device settings (MTU size).
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1361
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1362
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1363
static int __devinit
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1364
e1000_sw_init(struct e1000_adapter *adapter)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1365
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1366
	struct e1000_hw *hw = &adapter->hw;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1367
	struct net_device *netdev = adapter->netdev;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1368
	struct pci_dev *pdev = adapter->pdev;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1369
#ifdef CONFIG_E1000_NAPI
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1370
	int i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1371
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1372
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1373
	/* PCI config space info */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1374
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1375
	hw->vendor_id = pdev->vendor;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1376
	hw->device_id = pdev->device;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1377
	hw->subsystem_vendor_id = pdev->subsystem_vendor;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1378
	hw->subsystem_id = pdev->subsystem_device;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1379
	hw->revision_id = pdev->revision;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1380
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1381
	pci_read_config_word(pdev, PCI_COMMAND, &hw->pci_cmd_word);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1382
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1383
	adapter->rx_buffer_len = MAXIMUM_ETHERNET_VLAN_SIZE;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1384
	adapter->rx_ps_bsize0 = E1000_RXBUFFER_128;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1385
	hw->max_frame_size = netdev->mtu +
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1386
			     ENET_HEADER_SIZE + ETHERNET_FCS_SIZE;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1387
	hw->min_frame_size = MINIMUM_ETHERNET_FRAME_SIZE;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1388
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1389
	/* identify the MAC */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1390
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1391
	if (e1000_set_mac_type(hw)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1392
		DPRINTK(PROBE, ERR, "Unknown MAC Type\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1393
		return -EIO;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1394
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1395
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1396
	switch (hw->mac_type) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1397
	default:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1398
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1399
	case e1000_82541:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1400
	case e1000_82547:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1401
	case e1000_82541_rev_2:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1402
	case e1000_82547_rev_2:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1403
		hw->phy_init_script = 1;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1404
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1405
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1406
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1407
	e1000_set_media_type(hw);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1408
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1409
	hw->wait_autoneg_complete = false;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1410
	hw->tbi_compatibility_en = true;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1411
	hw->adaptive_ifs = true;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1412
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1413
	/* Copper options */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1414
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1415
	if (hw->media_type == e1000_media_type_copper) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1416
		hw->mdix = AUTO_ALL_MODES;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1417
		hw->disable_polarity_correction = false;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1418
		hw->master_slave = E1000_MASTER_SLAVE;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1419
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1420
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1421
	adapter->num_tx_queues = 1;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1422
	adapter->num_rx_queues = 1;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1423
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1424
	if (e1000_alloc_queues(adapter)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1425
		DPRINTK(PROBE, ERR, "Unable to allocate memory for queues\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1426
		return -ENOMEM;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1427
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1428
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1429
#ifdef CONFIG_E1000_NAPI
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1430
	for (i = 0; i < adapter->num_rx_queues; i++) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1431
		adapter->polling_netdev[i].priv = adapter;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1432
		dev_hold(&adapter->polling_netdev[i]);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1433
		set_bit(__LINK_STATE_START, &adapter->polling_netdev[i].state);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1434
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1435
	spin_lock_init(&adapter->tx_queue_lock);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1436
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1437
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1438
	/* Explicitly disable IRQ since the NIC can be in any state. */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1439
	e1000_irq_disable(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1440
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1441
	spin_lock_init(&adapter->stats_lock);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1442
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1443
	set_bit(__E1000_DOWN, &adapter->flags);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1444
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1445
	return 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1446
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1447
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1448
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1449
 * e1000_alloc_queues - Allocate memory for all rings
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1450
 * @adapter: board private structure to initialize
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1451
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1452
 * We allocate one ring per queue at run-time since we don't know the
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1453
 * number of queues at compile-time.  The polling_netdev array is
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1454
 * intended for Multiqueue, but should work fine with a single queue.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1455
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1456
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1457
static int __devinit
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1458
e1000_alloc_queues(struct e1000_adapter *adapter)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1459
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1460
	adapter->tx_ring = kcalloc(adapter->num_tx_queues,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1461
	                           sizeof(struct e1000_tx_ring), GFP_KERNEL);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1462
	if (!adapter->tx_ring)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1463
		return -ENOMEM;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1464
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1465
	adapter->rx_ring = kcalloc(adapter->num_rx_queues,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1466
	                           sizeof(struct e1000_rx_ring), GFP_KERNEL);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1467
	if (!adapter->rx_ring) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1468
		kfree(adapter->tx_ring);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1469
		return -ENOMEM;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1470
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1471
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1472
#ifdef CONFIG_E1000_NAPI
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1473
	adapter->polling_netdev = kcalloc(adapter->num_rx_queues,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1474
	                                  sizeof(struct net_device),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1475
	                                  GFP_KERNEL);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1476
	if (!adapter->polling_netdev) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1477
		kfree(adapter->tx_ring);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1478
		kfree(adapter->rx_ring);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1479
		return -ENOMEM;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1480
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1481
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1482
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1483
	return E1000_SUCCESS;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1484
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1485
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1486
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1487
 * e1000_open - Called when a network interface is made active
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1488
 * @netdev: network interface device structure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1489
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1490
 * Returns 0 on success, negative value on failure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1491
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1492
 * The open entry point is called when a network interface is made
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1493
 * active by the system (IFF_UP).  At this point all resources needed
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1494
 * for transmit and receive operations are allocated, the interrupt
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1495
 * handler is registered with the OS, the watchdog timer is started,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1496
 * and the stack is notified that the interface is ready.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1497
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1498
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1499
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1500
e1000_open(struct net_device *netdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1501
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1502
	struct e1000_adapter *adapter = netdev_priv(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1503
	int err;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1504
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1505
	/* disallow open during test */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1506
	if (test_bit(__E1000_TESTING, &adapter->flags))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1507
		return -EBUSY;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1508
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1509
	/* allocate transmit descriptors */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1510
	err = e1000_setup_all_tx_resources(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1511
	if (err)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1512
		goto err_setup_tx;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1513
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1514
	/* allocate receive descriptors */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1515
	err = e1000_setup_all_rx_resources(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1516
	if (err)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1517
		goto err_setup_rx;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1518
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1519
	e1000_power_up_phy(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1520
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1521
	adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1522
	if ((adapter->hw.mng_cookie.status &
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1523
			  E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1524
		e1000_update_mng_vlan(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1525
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1526
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1527
	/* If AMT is enabled, let the firmware know that the network
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1528
	 * interface is now open */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1529
	if (adapter->hw.mac_type == e1000_82573 &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1530
	    e1000_check_mng_mode(&adapter->hw))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1531
		e1000_get_hw_control(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1532
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1533
	/* before we allocate an interrupt, we must be ready to handle it.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1534
	 * Setting DEBUG_SHIRQ in the kernel makes it fire an interrupt
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1535
	 * as soon as we call pci_request_irq, so we have to setup our
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1536
	 * clean_rx handler before we do so.  */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1537
	e1000_configure(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1538
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1539
	err = e1000_request_irq(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1540
	if (err)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1541
		goto err_req_irq;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1542
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1543
	/* From here on the code is the same as e1000_up() */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1544
	clear_bit(__E1000_DOWN, &adapter->flags);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1545
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1546
#ifdef CONFIG_E1000_NAPI
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1547
	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
  1548
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1549
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1550
	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
  1551
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1552
	/* 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
  1553
	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
  1554
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1555
	return E1000_SUCCESS;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1556
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1557
err_req_irq:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1558
	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
  1559
	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
  1560
	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
  1561
err_setup_rx:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1562
	e1000_free_all_tx_resources(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1563
err_setup_tx:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1564
	e1000_reset(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1565
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1566
	return err;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1567
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1568
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1569
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1570
 * 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
  1571
 * @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
  1572
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1573
 * 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
  1574
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1575
 * 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
  1576
 * 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
  1577
 * 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
  1578
 * 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
  1579
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1580
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1581
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1582
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
  1583
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1584
	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
  1585
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1586
	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
  1587
	e1000_down(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1588
	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
  1589
	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
  1590
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1591
	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
  1592
	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
  1593
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1594
	/* 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
  1595
	 * 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
  1596
	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
  1597
			  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
  1598
	     !(adapter->vlgrp &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1599
	       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
  1600
		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
  1601
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1602
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1603
	/* 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
  1604
	 * 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
  1605
	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
  1606
	    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
  1607
		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
  1608
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1609
	return 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1610
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1611
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1612
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1613
 * 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
  1614
 * @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
  1615
 * @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
  1616
 * @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
  1617
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1618
static bool
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1619
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
  1620
		      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
  1621
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1622
	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
  1623
	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
  1624
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1625
	/* 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
  1626
	 * 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
  1627
	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
  1628
	    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
  1629
		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
  1630
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1631
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1632
	return 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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1636
 * 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
  1637
 * @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
  1638
 * @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
  1639
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1640
 * 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
  1641
 **/
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
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1644
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
  1645
                         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
  1646
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1647
	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
  1648
	int size;
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
	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
  1651
	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
  1652
	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
  1653
		DPRINTK(PROBE, ERR,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1654
		"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
  1655
		return -ENOMEM;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1656
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1657
	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
  1658
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1659
	/* 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
  1660
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1661
	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
  1662
	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
  1663
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1664
	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
  1665
	if (!txdr->desc) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1666
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
  1667
		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
  1668
		DPRINTK(PROBE, ERR,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1669
		"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
  1670
		return -ENOMEM;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1671
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1672
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1673
	/* 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
  1674
	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
  1675
		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
  1676
		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
  1677
		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
  1678
				     "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
  1679
		/* 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
  1680
		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
  1681
		/* 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
  1682
		if (!txdr->desc) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1683
			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
  1684
			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
  1685
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1686
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1687
		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
  1688
			/* give up */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1689
			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
  1690
					    txdr->dma);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1691
			pci_free_consistent(pdev, txdr->size, olddesc, olddma);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1692
			DPRINTK(PROBE, ERR,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1693
				"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
  1694
				"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
  1695
			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
  1696
			return -ENOMEM;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1697
		} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1698
			/* 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
  1699
			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
  1700
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1701
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1702
	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
  1703
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1704
	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
  1705
	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
  1706
	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
  1707
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1708
	return 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1709
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1710
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1711
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1712
 * 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
  1713
 * 				  (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
  1714
 * @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
  1715
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1716
 * 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
  1717
 **/
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
int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1720
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
  1721
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1722
	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
  1723
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1724
	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
  1725
		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
  1726
		if (err) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1727
			DPRINTK(PROBE, ERR,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1728
				"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
  1729
			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
  1730
				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
  1731
							&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
  1732
			break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1733
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1734
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1735
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1736
	return err;
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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1740
 * 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
  1741
 * @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
  1742
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1743
 * 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
  1744
 **/
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
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1747
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
  1748
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1749
	u64 tdba;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1750
	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
  1751
	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
  1752
	u32 ipgr1, ipgr2;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1753
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1754
	/* 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
  1755
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1756
	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
  1757
	case 1:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1758
	default:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1759
		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
  1760
		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
  1761
			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
  1762
		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
  1763
		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
  1764
		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
  1765
		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
  1766
		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
  1767
		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
  1768
		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
  1769
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1770
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1771
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1772
	/* 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
  1773
	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
  1774
	    (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
  1775
	     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
  1776
		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
  1777
	else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1778
		tipg = DEFAULT_82543_TIPG_IPGT_COPPER;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1779
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1780
	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
  1781
	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
  1782
	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
  1783
		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
  1784
		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
  1785
		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
  1786
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1787
	case e1000_80003es2lan:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1788
		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
  1789
		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
  1790
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1791
	default:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1792
		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
  1793
		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
  1794
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1795
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1796
	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
  1797
	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
  1798
	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
  1799
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1800
	/* 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
  1801
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1802
	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
  1803
	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
  1804
		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
  1805
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1806
	/* 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
  1807
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1808
	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
  1809
	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
  1810
	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
  1811
		(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
  1812
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1813
	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
  1814
		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
  1815
		/* 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
  1816
		 * gigabit link later */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1817
		tarc |= (1 << 21);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1818
		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
  1819
	} 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
  1820
		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
  1821
		tarc |= 1;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1822
		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
  1823
		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
  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, TARC1, tarc);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1826
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1827
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1828
	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
  1829
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1830
	/* 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
  1831
	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
  1832
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1833
	/* 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
  1834
	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
  1835
		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
  1836
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1837
	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
  1838
		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
  1839
	else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1840
		adapter->txd_cmd |= E1000_TXD_CMD_RS;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1841
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1842
	/* 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
  1843
	 * 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
  1844
	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
  1845
	    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
  1846
		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
  1847
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1848
	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
  1849
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
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
 * 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
  1854
 * @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
  1855
 * @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
  1856
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1857
 * 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
  1858
 **/
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
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1861
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
  1862
                         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
  1863
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1864
	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
  1865
	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
  1866
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1867
	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
  1868
	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
  1869
	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
  1870
		DPRINTK(PROBE, ERR,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1871
		"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
  1872
		return -ENOMEM;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1873
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1874
	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
  1875
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1876
	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
  1877
	                        GFP_KERNEL);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1878
	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
  1879
		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
  1880
		DPRINTK(PROBE, ERR,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1881
		"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
  1882
		return -ENOMEM;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1883
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1884
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1885
	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
  1886
	                            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
  1887
	                            GFP_KERNEL);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1888
	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
  1889
		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
  1890
		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
  1891
		DPRINTK(PROBE, ERR,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1892
		"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
  1893
		return -ENOMEM;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1894
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1895
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1896
	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
  1897
		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
  1898
	else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1899
		desc_len = sizeof(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
  1900
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1901
	/* 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
  1902
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1903
	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
  1904
	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
  1905
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1906
	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
  1907
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1908
	if (!rxdr->desc) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1909
		DPRINTK(PROBE, ERR,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1910
		"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
  1911
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
  1912
		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
  1913
		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
  1914
		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
  1915
		return -ENOMEM;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1916
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1917
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1918
	/* 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
  1919
	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
  1920
		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
  1921
		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
  1922
		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
  1923
				     "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
  1924
		/* 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
  1925
		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
  1926
		/* 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
  1927
		if (!rxdr->desc) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1928
			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
  1929
			DPRINTK(PROBE, ERR,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1930
				"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
  1931
				"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
  1932
			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
  1933
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1934
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1935
		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
  1936
			/* give up */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1937
			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
  1938
					    rxdr->dma);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1939
			pci_free_consistent(pdev, rxdr->size, olddesc, olddma);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1940
			DPRINTK(PROBE, ERR,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1941
				"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
  1942
				"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
  1943
			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
  1944
		} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1945
			/* 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
  1946
			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
  1947
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1948
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1949
	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
  1950
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1951
	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
  1952
	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
  1953
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1954
	return 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1955
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1956
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1957
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1958
 * e1000_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
  1959
 * 				  (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
  1960
 * @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
  1961
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1962
 * 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
  1963
 **/
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
int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1966
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
  1967
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1968
	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
  1969
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1970
	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
  1971
		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
  1972
		if (err) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1973
			DPRINTK(PROBE, ERR,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1974
				"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
  1975
			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
  1976
				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
  1977
							&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
  1978
			break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1979
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1980
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1981
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1982
	return err;
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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1986
 * 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
  1987
 * @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
  1988
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1989
#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
  1990
			(((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
  1991
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1992
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
  1993
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1994
	u32 rctl, rfctl;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1995
	u32 psrctl = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1996
#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
  1997
	u32 pages = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1998
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1999
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2000
	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
  2001
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2002
	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
  2003
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2004
	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
  2005
		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
  2006
		(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
  2007
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2008
	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
  2009
		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
  2010
	else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2011
		rctl &= ~E1000_RCTL_SBP;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2012
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2013
	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
  2014
		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
  2015
	else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2016
		rctl |= E1000_RCTL_LPE;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2017
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2018
	/* Setup buffer sizes */
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_SZ_4096;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2020
	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
  2021
	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
  2022
		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
  2023
			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
  2024
			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
  2025
			break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2026
		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
  2027
			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
  2028
			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
  2029
			break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2030
		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
  2031
			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
  2032
			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
  2033
			break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2034
		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
  2035
		default:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2036
			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
  2037
			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
  2038
			break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2039
		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
  2040
			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
  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_8192:
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_8192;
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_16384:
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_16384;
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
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2049
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2050
#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
  2051
	/* 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
  2052
	 * 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
  2053
	 * 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
  2054
	 * 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
  2055
	 * 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
  2056
	 * 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
  2057
	 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2058
	/* 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
  2059
	 * 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
  2060
	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
  2061
	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
  2062
	    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
  2063
		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
  2064
	else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2065
		adapter->rx_ps_pages = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2066
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2067
	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
  2068
		/* 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
  2069
		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
  2070
		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
  2071
		/* 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
  2072
		 * 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
  2073
		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
  2074
		          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
  2075
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2076
		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
  2077
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2078
		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
  2079
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2080
		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
  2081
			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
  2082
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2083
		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
  2084
		case 3:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2085
			psrctl |= PAGE_SIZE <<
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2086
				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
  2087
		case 2:
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_BSIZE2_SHIFT;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2090
		case 1:
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_BSIZE1_SHIFT;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2093
			break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2094
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2095
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2096
		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
  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, RCTL, rctl);
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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2103
 * 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
  2104
 * @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
  2105
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2106
 * 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
  2107
 **/
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
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2110
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
  2111
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2112
	u64 rdba;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2113
	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
  2114
	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
  2115
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2116
	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
  2117
		/* 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
  2118
		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
  2119
			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
  2120
		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
  2121
		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
  2122
	} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2123
		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
  2124
			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
  2125
		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
  2126
		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
  2127
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2128
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2129
	/* 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
  2130
	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
  2131
	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
  2132
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2133
	/* 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
  2134
	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
  2135
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2136
	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
  2137
		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
  2138
		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
  2139
			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
  2140
				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
  2141
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2142
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2143
	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
  2144
		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
  2145
		/* 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
  2146
		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
  2147
#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
  2148
		/* 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
  2149
		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
  2150
		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
  2151
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2152
		E1000_WRITE_REG(hw, 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
  2153
		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
  2154
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2155
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2156
	/* 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
  2157
	 * 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
  2158
	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
  2159
	case 1:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2160
	default:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2161
		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
  2162
		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
  2163
		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
  2164
		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
  2165
		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
  2166
		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
  2167
		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
  2168
		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
  2169
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2170
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2171
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2172
	/* 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
  2173
	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
  2174
		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
  2175
		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
  2176
			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
  2177
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2178
			/* 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
  2179
			 * 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
  2180
			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
  2181
			    (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
  2182
				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
  2183
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2184
		} else {
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_TUOFL;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2186
			/* 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
  2187
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2188
		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
  2189
	}
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
	/* 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
  2192
	 * 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
  2193
#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
  2194
	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
  2195
		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
  2196
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2197
	/* Enable Receives */
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, RCTL, rctl);
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2201
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2202
 * 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
  2203
 * @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
  2204
 * @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
  2205
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2206
 * 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
  2207
 **/
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
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2210
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
  2211
                        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
  2212
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2213
	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
  2214
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2215
	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
  2216
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2217
	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
  2218
	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
  2219
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2220
	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
  2221
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2222
	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
  2223
}
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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2226
 * 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
  2227
 * @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
  2228
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2229
 * 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
  2230
 **/
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
void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2233
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
  2234
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2235
	int i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2236
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2237
	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
  2238
		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
  2239
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2240
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2241
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2242
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
  2243
			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
  2244
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2245
	if (adapter->ecdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2246
		return;
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 (buffer_info->dma) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2249
		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
  2250
				buffer_info->dma,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2251
				buffer_info->length,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2252
				PCI_DMA_TODEVICE);
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 = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2254
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2255
	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
  2256
		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
  2257
		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
  2258
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2259
	/* 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
  2260
}
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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2263
 * 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
  2264
 * @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
  2265
 * @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
  2266
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2267
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2268
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2269
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
  2270
                    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
  2271
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2272
	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
  2273
	unsigned long size;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2274
	unsigned int i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2275
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2276
	/* 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
  2277
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2278
	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
  2279
		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
  2280
		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
  2281
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2282
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2283
	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
  2284
	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
  2285
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2286
	/* 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
  2287
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2288
	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
  2289
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2290
	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
  2291
	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
  2292
	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
  2293
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2294
	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
  2295
	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
  2296
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2297
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2298
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2299
 * 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
  2300
 * @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
  2301
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2302
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2303
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2304
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
  2305
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2306
	int i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2307
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2308
	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
  2309
		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
  2310
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2311
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2312
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2313
 * 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
  2314
 * @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
  2315
 * @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
  2316
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2317
 * 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
  2318
 **/
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
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2321
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
  2322
                        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
  2323
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2324
	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
  2325
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2326
	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
  2327
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2328
	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
  2329
	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
  2330
	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
  2331
	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
  2332
	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
  2333
	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
  2334
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2335
	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
  2336
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2337
	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
  2338
}
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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2341
 * 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
  2342
 * @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
  2343
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2344
 * 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
  2345
 **/
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
void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2348
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
  2349
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2350
	int i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2351
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2352
	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
  2353
		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
  2354
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2355
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2356
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2357
 * 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
  2358
 * @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
  2359
 * @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
  2360
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2361
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2362
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2363
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
  2364
                    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
  2365
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2366
	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
  2367
	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
  2368
	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
  2369
	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
  2370
	unsigned long size;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2371
	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
  2372
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2373
	/* 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
  2374
	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
  2375
		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
  2376
		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
  2377
			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
  2378
					 buffer_info->dma,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2379
					 buffer_info->length,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2380
					 PCI_DMA_FROMDEVICE);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2381
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2382
			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
  2383
			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
  2384
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2385
		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
  2386
		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
  2387
		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
  2388
			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
  2389
			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
  2390
				       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
  2391
				       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
  2392
			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
  2393
			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
  2394
			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
  2395
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2396
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2397
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2398
	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
  2399
	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
  2400
	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
  2401
	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
  2402
	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
  2403
	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
  2404
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2405
	/* 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
  2406
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2407
	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
  2408
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2409
	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
  2410
	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
  2411
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2412
	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
  2413
	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
  2414
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2415
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2416
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2417
 * 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
  2418
 * @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
  2419
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2420
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2421
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2422
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
  2423
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2424
	int i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2425
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2426
	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
  2427
		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
  2428
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2429
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2430
/* 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
  2431
 * 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
  2432
 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2433
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2434
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
  2435
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2436
	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
  2437
	u32 rctl;
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
	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
  2440
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2441
	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
  2442
	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
  2443
	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
  2444
	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
  2445
	mdelay(5);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2446
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2447
	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
  2448
		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
  2449
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2450
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2451
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2452
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
  2453
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2454
	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
  2455
	u32 rctl;
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
	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
  2458
	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
  2459
	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
  2460
	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
  2461
	mdelay(5);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2462
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2463
	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
  2464
		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
  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->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
  2467
		/* 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
  2468
		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
  2469
		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
  2470
		if (adapter->ecdev) { 
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2471
			/* 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
  2472
			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
  2473
		} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2474
            /* 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
  2475
			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
  2476
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2477
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2478
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2479
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2480
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2481
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2482
 * 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
  2483
 * @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
  2484
 * @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
  2485
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2486
 * 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
  2487
 **/
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
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2490
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
  2491
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2492
	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
  2493
	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
  2494
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2495
	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
  2496
		return -EADDRNOTAVAIL;
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
	/* 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
  2499
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2500
	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
  2501
		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
  2502
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2503
	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
  2504
	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
  2505
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2506
	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
  2507
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2508
	/* 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
  2509
	 * 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
  2510
	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
  2511
		/* 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
  2512
		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
  2513
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2514
		/* 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
  2515
		 * 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
  2516
		 * 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
  2517
		 * 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
  2518
		 * 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
  2519
		 * RAR[14] */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2520
		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
  2521
					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
  2522
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2523
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2524
	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
  2525
		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
  2526
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2527
	return 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2528
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2529
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2530
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2531
 * 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
  2532
 * @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
  2533
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2534
 * 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
  2535
 * 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
  2536
 * 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
  2537
 * 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
  2538
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2539
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2540
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2541
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
  2542
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2543
	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
  2544
	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
  2545
	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
  2546
	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
  2547
	u32 rctl;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2548
	u32 hash_value;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2549
	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
  2550
	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
  2551
				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
  2552
				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
  2553
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2554
	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
  2555
		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
  2556
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2557
	/* 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
  2558
	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
  2559
		rar_entries--;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2560
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2561
	/* 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
  2562
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2563
	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
  2564
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2565
	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
  2566
		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
  2567
	} 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
  2568
		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
  2569
	} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2570
		rctl &= ~E1000_RCTL_MPE;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2571
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2572
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2573
	uc_ptr = NULL;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2574
	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
  2575
		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
  2576
	} 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
  2577
		rctl &= ~E1000_RCTL_UPE;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2578
		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
  2579
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2580
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2581
	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
  2582
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2583
	/* 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
  2584
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2585
	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
  2586
		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
  2587
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2588
	/* 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
  2589
	 * 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
  2590
	 * when possible.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2591
	 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2592
	 * 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
  2593
	 * 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
  2594
	 * -- 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
  2595
	 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2596
	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
  2597
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2598
	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
  2599
		if (uc_ptr) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2600
			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
  2601
			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
  2602
		} 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
  2603
			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
  2604
			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
  2605
		} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2606
			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
  2607
			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
  2608
			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
  2609
			E1000_WRITE_FLUSH(hw);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2610
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2611
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2612
	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
  2613
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2614
	/* 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
  2615
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2616
	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
  2617
		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
  2618
		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
  2619
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2620
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2621
	/* 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
  2622
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2623
	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
  2624
		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
  2625
		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
  2626
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2627
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2628
	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
  2629
		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
  2630
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2631
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2632
/* 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
  2633
 * the phy */
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
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2636
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
  2637
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2638
	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
  2639
	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
  2640
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2641
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2642
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2643
 * 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
  2644
 * @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
  2645
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2646
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2647
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2648
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
  2649
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2650
	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
  2651
	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
  2652
	u32 tctl;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2653
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2654
	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
  2655
		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
  2656
		    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
  2657
		   (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
  2658
		    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
  2659
		   (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
  2660
		    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
  2661
			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
  2662
			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
  2663
					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
  2664
			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
  2665
					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
  2666
			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
  2667
					adapter->tx_head_addr);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2668
			E1000_WRITE_REG(&adapter->hw, TDFTS,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2669
					adapter->tx_head_addr);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2670
			E1000_WRITE_REG(&adapter->hw, TDFHS,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2671
					adapter->tx_head_addr);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2672
			E1000_WRITE_REG(&adapter->hw, TCTL, tctl);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2673
			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
  2674
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2675
			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
  2676
			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
  2677
			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
  2678
		} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2679
			if (!adapter->ecdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2680
				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
  2681
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2682
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2683
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2684
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2685
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2686
 * 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
  2687
 * @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
  2688
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2689
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2690
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
  2691
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2692
	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
  2693
	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
  2694
	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
  2695
	u32 link, tctl;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2696
	s32 ret_val;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2697
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2698
	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
  2699
	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
  2700
	    (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
  2701
	    (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
  2702
		/* 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
  2703
		DPRINTK(LINK, INFO,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2704
			"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
  2705
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2706
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2707
	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
  2708
		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
  2709
		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
  2710
			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
  2711
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2712
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2713
	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
  2714
	   !(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
  2715
		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
  2716
	else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2717
		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
  2718
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2719
	if (link) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2720
		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
  2721
				|| (!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
  2722
			u32 ctrl;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2723
			bool txb2b = true;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2724
			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
  2725
			                           &adapter->link_speed,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2726
			                           &adapter->link_duplex);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2727
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2728
			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
  2729
			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
  2730
			        "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
  2731
			        adapter->link_speed,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2732
			        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
  2733
			        "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
  2734
			        ((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
  2735
			        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
  2736
			        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
  2737
			        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
  2738
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2739
			/* 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
  2740
			 * 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
  2741
			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
  2742
			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
  2743
			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
  2744
			case SPEED_10:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2745
				txb2b = false;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2746
				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
  2747
				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
  2748
				break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2749
			case SPEED_100:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2750
				txb2b = false;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2751
				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
  2752
				/* 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
  2753
				break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2754
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2755
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2756
			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
  2757
			     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
  2758
			    !txb2b) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2759
				u32 tarc0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2760
				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
  2761
				tarc0 &= ~(1 << 21);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2762
				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
  2763
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2764
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2765
			/* 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
  2766
			 * some hardware issues */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2767
			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
  2768
			    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
  2769
				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
  2770
				case SPEED_10:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2771
				case SPEED_100:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2772
					DPRINTK(PROBE,INFO,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2773
				        "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
  2774
					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
  2775
					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
  2776
					break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2777
				case SPEED_1000:
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_TSO;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2779
					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
  2780
					break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2781
				default:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2782
					/* oops */
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
				}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2785
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2786
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2787
			/* 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
  2788
			 * after setting TARC0 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2789
			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
  2790
			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
  2791
			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
  2792
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2793
			if (adapter->ecdev) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2794
				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
  2795
			} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2796
				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
  2797
				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
  2798
				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
  2799
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2800
			adapter->smartspeed = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2801
		} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2802
			/* 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
  2803
			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
  2804
				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
  2805
				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
  2806
				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
  2807
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2808
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2809
	} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2810
		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
  2811
				|| (!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
  2812
			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
  2813
			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
  2814
			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
  2815
			if (adapter->ecdev) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2816
				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
  2817
			} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2818
				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
  2819
				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
  2820
				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
  2821
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2822
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2823
			/* 80003ES2LAN workaround--
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2824
			 * 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
  2825
			 * 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
  2826
			 * 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
  2827
			 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2828
			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
  2829
				/* reset device */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2830
				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
  2831
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2832
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2833
		e1000_smartspeed(adapter);
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_update_stats(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
	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
  2839
	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
  2840
	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
  2841
	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
  2842
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2843
	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
  2844
	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
  2845
	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
  2846
	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
  2847
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2848
	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
  2849
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2850
	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
  2851
		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
  2852
			/* 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
  2853
			 * 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
  2854
			 * 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
  2855
			 * (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
  2856
			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
  2857
			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
  2858
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2859
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2860
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2861
	/* 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
  2862
	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
  2863
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2864
	/* 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
  2865
	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
  2866
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2867
	/* 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
  2868
	 * 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
  2869
	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
  2870
		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
  2871
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2872
	/* Reset the timer */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2873
	if (!adapter->ecdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2874
		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
  2875
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2876
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2877
enum latency_range {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2878
	lowest_latency = 0,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2879
	low_latency = 1,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2880
	bulk_latency = 2,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2881
	latency_invalid = 255
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2882
};
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2883
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2884
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2885
 * 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
  2886
 *      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
  2887
 *      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
  2888
 *      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
  2889
 *      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
  2890
 *      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
  2891
 *      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
  2892
 *      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
  2893
 *      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
  2894
 *      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
  2895
 * @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
  2896
 * @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
  2897
 * @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
  2898
 * @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
  2899
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2900
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
  2901
                                   u16 itr_setting,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2902
                                   int packets,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2903
                                   int bytes)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2904
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2905
	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
  2906
	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
  2907
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2908
	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
  2909
		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
  2910
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2911
	if (packets == 0)
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
	switch (itr_setting) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2915
	case lowest_latency:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2916
		/* 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
  2917
		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
  2918
			retval = bulk_latency;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2919
		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
  2920
			retval = low_latency;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2921
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2922
	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
  2923
		if (bytes > 10000) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2924
			/* 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
  2925
			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
  2926
				retval = bulk_latency;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2927
			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
  2928
				retval = bulk_latency;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2929
			else if ((packets > 35))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2930
				retval = lowest_latency;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2931
		} else if (bytes/packets > 2000)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2932
			retval = bulk_latency;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2933
		else if (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
  2934
			retval = lowest_latency;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2935
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2936
	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
  2937
		if (bytes > 25000) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2938
			if (packets > 35)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2939
				retval = low_latency;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2940
		} 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
  2941
			retval = low_latency;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2942
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2943
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2944
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2945
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2946
update_itr_done:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2947
	return retval;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2950
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
  2951
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2952
	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
  2953
	u16 current_itr;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2954
	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
  2955
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2956
	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
  2957
		return;
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
	/* 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
  2960
	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
  2961
		current_itr = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2962
		new_itr = 4000;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2963
		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
  2964
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2965
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2966
	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
  2967
	                            adapter->tx_itr,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2968
	                            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
  2969
	                            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
  2970
	/* 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
  2971
	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
  2972
		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
  2973
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2974
	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
  2975
	                            adapter->rx_itr,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2976
	                            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
  2977
	                            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
  2978
	/* 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
  2979
	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
  2980
		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
  2981
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2982
	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
  2983
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2984
	switch (current_itr) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2985
	/* 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
  2986
	case lowest_latency:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2987
		new_itr = 70000;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2988
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2989
	case low_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 = 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
  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 bulk_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 = 4000;
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
	default:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2996
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2997
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2998
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2999
set_itr_now:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3000
	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
  3001
		/* 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
  3002
		 * 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
  3003
		 * increasing */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3004
		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
  3005
		             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
  3006
		             new_itr;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3007
		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
  3008
		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
  3009
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3010
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3011
	return;
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
#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
  3015
#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
  3016
#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
  3017
#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
  3018
#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
  3019
#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
  3020
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3021
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3022
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
  3023
          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
  3024
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3025
	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
  3026
	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
  3027
	unsigned int i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3028
	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
  3029
	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
  3030
	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
  3031
	int err;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3032
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3033
	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
  3034
		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
  3035
			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
  3036
			if (err)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3037
				return err;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3038
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3039
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3040
		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
  3041
		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
  3042
		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
  3043
			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
  3044
			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
  3045
			iph->check = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3046
			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
  3047
								 iph->daddr, 0,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3048
								 IPPROTO_TCP,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3049
								 0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3050
			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
  3051
			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
  3052
		} 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
  3053
			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
  3054
			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
  3055
				~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
  3056
						 &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
  3057
						 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
  3058
			ipcse = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3059
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3060
		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
  3061
		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
  3062
		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
  3063
		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
  3064
		tucse = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3065
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3066
		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
  3067
			       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
  3068
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3069
		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
  3070
		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
  3071
		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
  3072
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3073
		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
  3074
		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
  3075
		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
  3076
		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
  3077
		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
  3078
		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
  3079
		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
  3080
		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
  3081
		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
  3082
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3083
		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
  3084
		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
  3085
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3086
		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
  3087
		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
  3088
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3089
		return true;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3090
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3091
	return false;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3092
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3093
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3094
static bool
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3095
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
  3096
              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
  3097
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3098
	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
  3099
	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
  3100
	unsigned int i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3101
	u8 css;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3102
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3103
	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
  3104
		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
  3105
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3106
		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
  3107
		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
  3108
		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
  3109
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3110
		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
  3111
		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
  3112
		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
  3113
			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
  3114
		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
  3115
		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
  3116
		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
  3117
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3118
		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
  3119
		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
  3120
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3121
		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
  3122
		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
  3123
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3124
		return true;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3125
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3126
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3127
	return false;
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
#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
  3131
#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
  3132
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3133
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3134
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
  3135
             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
  3136
             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
  3137
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3138
	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
  3139
	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
  3140
	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
  3141
	unsigned int f;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3142
	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
  3143
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3144
	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
  3145
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3146
	while (len) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3147
		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
  3148
		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
  3149
		/* 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
  3150
		 * 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
  3151
		 * 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
  3152
		 * 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
  3153
		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
  3154
		    !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
  3155
			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
  3156
			size -= 4;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3157
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3158
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3159
		/* 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
  3160
		 * 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
  3161
		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
  3162
			size -= 4;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3163
		/* 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
  3164
		 * 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
  3165
		 * 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
  3166
		 * 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
  3167
		 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3168
		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
  3169
		                (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
  3170
		        size = 2015;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3171
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3172
		/* 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
  3173
		 * 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
  3174
		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
  3175
		   !((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
  3176
		   size > 4))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3177
			size -= 4;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3178
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3179
		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
  3180
		buffer_info->dma =
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3181
			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
  3182
				skb->data + offset,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3183
				size,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3184
				PCI_DMA_TODEVICE);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3185
		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
  3186
		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
  3187
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3188
		len -= size;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3189
		offset += size;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3190
		count++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3191
		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
  3192
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3193
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3194
	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
  3195
		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
  3196
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3197
		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
  3198
		len = frag->size;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3199
		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
  3200
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3201
		while (len) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3202
			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
  3203
			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
  3204
			/* 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
  3205
			 * 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
  3206
			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
  3207
				size -= 4;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3208
			/* 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
  3209
			 * 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
  3210
			 * dwords. */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3211
			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
  3212
			   !((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
  3213
			   size > 4))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3214
				size -= 4;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3215
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3216
			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
  3217
			buffer_info->dma =
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3218
				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
  3219
					frag->page,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3220
					offset,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3221
					size,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3222
					PCI_DMA_TODEVICE);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3223
			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
  3224
			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
  3225
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3226
			len -= size;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3227
			offset += size;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3228
			count++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3229
			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
  3230
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3231
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3232
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3233
	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
  3234
	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
  3235
	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
  3236
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3237
	return count;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3238
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3239
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3240
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3241
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
  3242
               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
  3243
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3244
	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
  3245
	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
  3246
	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
  3247
	unsigned int i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3248
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3249
	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
  3250
		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
  3251
		             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
  3252
		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
  3253
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3254
		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
  3255
			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
  3256
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3257
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3258
	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
  3259
		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
  3260
		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
  3261
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3262
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3263
	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
  3264
		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
  3265
		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
  3266
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3267
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3268
	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
  3269
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3270
	while (count--) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3271
		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
  3272
		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
  3273
		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
  3274
		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
  3275
			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
  3276
		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
  3277
		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
  3278
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3279
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3280
	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
  3281
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3282
	/* 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
  3283
	 * 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
  3284
	 * 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
  3285
	 * 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
  3286
	wmb();
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3287
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3288
	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
  3289
	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
  3290
	/* 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
  3291
	 * 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
  3292
	mmiowb();
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3293
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3294
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3295
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3296
 * 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
  3297
 * 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
  3298
 * 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
  3299
 * 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
  3300
 * 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
  3301
 * 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
  3302
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3303
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3304
#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
  3305
#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
  3306
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3307
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3308
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
  3309
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3310
	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
  3311
	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
  3312
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3313
	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
  3314
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3315
	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
  3316
		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
  3317
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3318
	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
  3319
		return 1;
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 (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
  3322
		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
  3323
		return 1;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3324
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3325
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3326
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
  3327
	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
  3328
	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
  3329
		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
  3330
	return 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3331
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3332
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3333
#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
  3334
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3335
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
  3336
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3337
	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
  3338
	u16 length, offset;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3339
	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
  3340
		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
  3341
			( 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
  3342
			  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
  3343
			return 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3344
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3345
	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
  3346
		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
  3347
		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
  3348
			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
  3349
				(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
  3350
			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
  3351
				struct udphdr *udp =
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3352
					(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
  3353
						(ip->ihl << 2));
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3354
				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
  3355
					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
  3356
					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
  3357
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3358
					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
  3359
							(u8 *)udp + 8,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3360
							length);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3361
				}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3362
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3363
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3364
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3365
	return 0;
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
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
  3369
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3370
	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
  3371
	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
  3372
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3373
	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
  3374
	/* 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
  3375
	 *  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
  3376
	 * 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
  3377
	smp_mb();
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3378
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3379
	/* 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
  3380
	 * made room available. */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3381
	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
  3382
		return -EBUSY;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3383
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3384
	/* A reprieve! */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3385
	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
  3386
	++adapter->restart_queue;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3387
	return 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3388
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3389
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3390
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
  3391
                               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
  3392
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3393
	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
  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
	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
  3396
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3397
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3398
#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
  3399
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3400
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
  3401
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3402
	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
  3403
	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
  3404
	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
  3405
	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
  3406
	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
  3407
	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
  3408
	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
  3409
	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
  3410
	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
  3411
	int count = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3412
	int tso;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3413
	unsigned int f;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3414
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3415
	/* 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
  3416
	 * 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
  3417
	 * 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
  3418
	 * 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
  3419
	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
  3420
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3421
	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
  3422
		if (!adapter->ecdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3423
			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
  3424
		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
  3425
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3426
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3427
	/* 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
  3428
	 * length to 4kB */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3429
	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
  3430
		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
  3431
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3432
	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
  3433
	/* 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
  3434
	 * 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
  3435
	 * 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
  3436
	 * 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
  3437
	 * 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
  3438
	 * drops. */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3439
	if (mss) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3440
		u8 hdr_len;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3441
		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
  3442
		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
  3443
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3444
		/* 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
  3445
		* 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
  3446
		* 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
  3447
		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
  3448
		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
  3449
			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
  3450
				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
  3451
			case e1000_82544:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3452
				/* 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
  3453
				 * 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
  3454
				 * 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
  3455
				 * 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
  3456
				 * 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
  3457
				 * 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
  3458
				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
  3459
					break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3460
				/* fall through */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3461
			case e1000_82571:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3462
			case e1000_82572:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3463
			case e1000_82573:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3464
			case e1000_ich8lan:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3465
				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
  3466
				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
  3467
					DPRINTK(DRV, ERR,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3468
						"__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
  3469
					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
  3470
					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
  3471
				}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3472
				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
  3473
				break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3474
			default:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3475
				/* do nothing */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3476
				break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3477
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3478
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3479
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3480
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3481
	/* 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
  3482
	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
  3483
		count++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3484
	count++;
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
	/* Controller Erratum workaround */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3487
	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
  3488
		count++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3489
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3490
	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
  3491
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3492
	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
  3493
		count++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3494
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3495
	/* 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
  3496
	 * 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
  3497
	 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3498
	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
  3499
			(len > 2015)))
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
	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
  3503
	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
  3504
		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
  3505
				       max_txd_pwr);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3506
	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
  3507
		count += nr_frags;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3510
	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
  3511
	    (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
  3512
		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
  3513
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3514
	if (!adapter->ecdev &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3515
			!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
  3516
		/* 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
  3517
		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
  3518
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3519
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3520
	/* 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
  3521
	 * 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
  3522
	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
  3523
		if (!adapter->ecdev) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3524
			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
  3525
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3526
		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
  3527
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3528
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3529
	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
  3530
		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
  3531
			if (!adapter->ecdev) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3532
				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
  3533
				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
  3534
				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
  3535
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3536
			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
  3537
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3538
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3539
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3540
	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
  3541
		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
  3542
		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
  3543
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3544
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3545
	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
  3546
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3547
	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
  3548
	if (tso < 0) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3549
		if (!adapter->ecdev) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3550
			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
  3551
			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
  3552
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3553
		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
  3554
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3555
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3556
	if (likely(tso)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3557
		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
  3558
		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
  3559
	} 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
  3560
		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
  3561
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3562
	/* 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
  3563
	 * 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
  3564
	 * 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
  3565
	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
  3566
		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
  3567
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3568
	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
  3569
	               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
  3570
	                            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
  3571
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3572
	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
  3573
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3574
	if (!adapter->ecdev) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3575
		/* 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
  3576
		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
  3577
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3578
		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
  3579
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3580
	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
  3581
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3582
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3583
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3584
 * 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
  3585
 * @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
  3586
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3587
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3588
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3589
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
  3590
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3591
	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
  3592
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3593
	/* 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
  3594
	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
  3595
	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
  3596
}
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
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3599
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
  3600
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3601
	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
  3602
		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
  3603
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3604
	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
  3605
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3606
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3607
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3608
 * 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
  3609
 * @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
  3610
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3611
 * 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
  3612
 * 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
  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
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
  3616
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
  3617
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3618
	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
  3619
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3620
	/* 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
  3621
	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
  3622
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3623
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3624
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3625
 * 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
  3626
 * @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
  3627
 * @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
  3628
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3629
 * 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
  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
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3633
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
  3634
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3635
	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
  3636
	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
  3637
	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
  3638
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3639
	if (adapter->ecdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3640
		return -EBUSY;
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
	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
  3643
	    (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
  3644
		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
  3645
		return -EINVAL;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3646
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3647
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3648
	/* 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
  3649
	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
  3650
	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
  3651
	case e1000_ich8lan:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3652
		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
  3653
			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
  3654
			return -EINVAL;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3655
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3656
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3657
	case e1000_82573:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3658
		/* 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
  3659
		 * - 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
  3660
		 * - 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
  3661
		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
  3662
		                  &eeprom_data);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3663
		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
  3664
		    (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
  3665
			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
  3666
				DPRINTK(PROBE, ERR,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3667
			            	"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
  3668
				return -EINVAL;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3669
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3670
			break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3671
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3672
		/* 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
  3673
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3674
		/* 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
  3675
	case e1000_82571:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3676
	case e1000_82572:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3677
	case e1000_80003es2lan:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3678
#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
  3679
		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
  3680
			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
  3681
			return -EINVAL;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3682
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3683
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3684
	default:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3685
		/* 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
  3686
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3687
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3688
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3689
	/* 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
  3690
	 * 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
  3691
	 * larger slab size
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3692
	 * 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
  3693
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3694
	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
  3695
		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
  3696
	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
  3697
		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
  3698
	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
  3699
		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
  3700
	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
  3701
		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
  3702
	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
  3703
		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
  3704
	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
  3705
		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
  3706
	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
  3707
		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
  3708
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3709
	/* 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
  3710
	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
  3711
	    ((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
  3712
	     (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
  3713
		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
  3714
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3715
	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
  3716
	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
  3717
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3718
	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
  3719
		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
  3720
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3721
	return 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3722
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3723
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3724
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3725
 * 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
  3726
 * @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
  3727
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3728
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3729
void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3730
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
  3731
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3732
	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
  3733
	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
  3734
	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
  3735
	u16 phy_tmp;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3736
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3737
#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
  3738
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3739
	/*
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3740
	 * 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
  3741
	 * connection is down.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3742
	 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3743
	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
  3744
		return;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3745
	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
  3746
		return;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3747
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3748
	if (!adapter->ecdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3749
		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
  3750
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3751
	/* 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
  3752
	 * 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
  3753
	 * 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
  3754
	 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3755
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3756
	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
  3757
	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
  3758
	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
  3759
	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
  3760
	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
  3761
	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
  3762
	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
  3763
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3764
	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
  3765
		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
  3766
		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
  3767
		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
  3768
		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
  3769
		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
  3770
		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
  3771
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3772
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3773
	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
  3774
	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
  3775
	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
  3776
	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
  3777
	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
  3778
	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
  3779
	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
  3780
	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
  3781
	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
  3782
	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
  3783
	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
  3784
	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
  3785
	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
  3786
	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
  3787
	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
  3788
	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
  3789
	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
  3790
	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
  3791
	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
  3792
	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
  3793
	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
  3794
	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
  3795
	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
  3796
	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
  3797
	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
  3798
	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
  3799
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3800
	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
  3801
		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
  3802
		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
  3803
		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
  3804
		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
  3805
		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
  3806
		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
  3807
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3808
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3809
	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
  3810
	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
  3811
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3812
	/* 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
  3813
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3814
	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
  3815
	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
  3816
	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
  3817
	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
  3818
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3819
	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
  3820
		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
  3821
		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
  3822
		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
  3823
		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
  3824
		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
  3825
		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
  3826
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3827
	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
  3828
		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
  3829
		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
  3830
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3831
		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
  3832
			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
  3833
			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
  3834
			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
  3835
			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
  3836
			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
  3837
			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
  3838
			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
  3839
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3840
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3841
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3842
	/* 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
  3843
	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
  3844
	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
  3845
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3846
	/* Rx Errors */
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
	/* 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
  3849
	* 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
  3850
	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
  3851
		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
  3852
		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
  3853
		adapter->stats.cexterr;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3854
	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
  3855
	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
  3856
	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
  3857
	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
  3858
	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
  3859
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3860
	/* Tx Errors */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3861
	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
  3862
	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
  3863
	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
  3864
	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
  3865
	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
  3866
	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
  3867
	    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
  3868
		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
  3869
		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
  3870
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3871
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3872
	/* 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
  3873
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3874
	/* Phy Stats */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3875
	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
  3876
		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
  3877
		   (!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
  3878
			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
  3879
			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
  3880
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3881
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3882
		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
  3883
		   (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
  3884
		   !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
  3885
			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
  3886
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3887
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3888
	/* Management Stats */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3889
	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
  3890
		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
  3891
		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
  3892
		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
  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
	if (!adapter->ecdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3896
		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
  3897
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3898
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3899
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
  3900
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3901
    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
  3902
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3903
    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
  3904
        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
  3905
        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
  3906
    }
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
#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
  3909
	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
  3910
#else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3911
    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
  3912
#endif
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
/**
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 - Interrupt Handler
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3917
 * @irq: interrupt number
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3918
 * @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
  3919
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3920
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3921
static irqreturn_t
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3922
e1000_intr_msi(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
  3923
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3924
	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
  3925
	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
  3926
	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
  3927
	
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3928
	int i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3929
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3930
	if (adapter->ecdev) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3931
#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
  3932
		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
  3933
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3934
		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
  3935
#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
  3936
			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
  3937
                            &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
  3938
						!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
  3939
#else
2050
a3e59f2a8589 Changed accidentally used & operator to &&.
Florian Pose <fp@igh-essen.com>
parents: 1360
diff changeset
  3940
			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
  3941
						!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
  3942
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3943
				break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3944
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3945
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3946
	} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3947
		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
  3948
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3949
		/* 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
  3950
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3951
		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
  3952
			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
  3953
			/* 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
  3954
			 * 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
  3955
			 * adapter in watchdog */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3956
			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
  3957
			    (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
  3958
				/* disable receives */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3959
				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
  3960
				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
  3961
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3962
			/* 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
  3963
			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
  3964
				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
  3965
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3966
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3967
#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
  3968
		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
  3969
			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
  3970
			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
  3971
			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
  3972
			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
  3973
			__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
  3974
		} else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3975
			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
  3976
#else
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_bytes = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3978
		adapter->total_rx_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_tx_packets = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3980
		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
  3981
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3982
		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
  3983
			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
  3984
			   !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
  3985
				break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3986
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3987
		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
  3988
			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
  3989
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3990
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3991
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3992
	return IRQ_HANDLED;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3995
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3996
 * 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
  3997
 * @irq: interrupt number
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3998
 * @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
  3999
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4000
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4001
static irqreturn_t
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4002
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
  4003
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4004
	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
  4005
	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
  4006
	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
  4007
	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
  4008
	int i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4009
	if (unlikely(!icr))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4010
		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
  4011
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4012
#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
  4013
	/* 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
  4014
	 * 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
  4015
	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
  4016
	             !(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
  4017
		return IRQ_NONE;
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
	/* 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
  4020
	 * 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
  4021
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4022
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4023
	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
  4024
		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
  4025
		/* 80003ES2LAN workaround--
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4026
		 * 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
  4027
		 * 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
  4028
		 * 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
  4029
		 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4030
		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
  4031
		    (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
  4032
			/* disable receives */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4033
			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
  4034
			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
  4035
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4036
		/* 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
  4037
		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
  4038
			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
  4039
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4040
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4041
	if (adapter->ecdev) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4042
#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
  4043
			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
  4044
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4045
			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
  4046
#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
  4047
				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
  4048
		                    &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
  4049
							!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
  4050
#else
2050
a3e59f2a8589 Changed accidentally used & operator to &&.
Florian Pose <fp@igh-essen.com>
parents: 1360
diff changeset
  4051
				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
  4052
							!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
  4053
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4054
					break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4055
				}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4056
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4057
	} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4058
#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
  4059
		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
  4060
			/* 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
  4061
			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
  4062
			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
  4063
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4064
		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
  4065
			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
  4066
			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
  4067
			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
  4068
			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
  4069
			__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
  4070
		} else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4071
			/* 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
  4072
			 * 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
  4073
			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
  4074
#else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4075
		/* 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
  4076
		 * 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
  4077
		 * 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
  4078
		 * 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
  4079
		 * 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
  4080
		 * 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
  4081
		 * 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
  4082
		 * 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
  4083
		 * de-assertion state.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4084
		 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4085
		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
  4086
			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
  4087
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4088
		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
  4089
		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
  4090
		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
  4091
		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
  4092
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4093
		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
  4094
			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
  4095
			   !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
  4096
				break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4097
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4098
		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
  4099
			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
  4100
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4101
		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
  4102
			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
  4103
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4104
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4105
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4106
	
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4107
	return IRQ_HANDLED;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4108
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4109
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4110
#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
  4111
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4112
 * 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
  4113
 * @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
  4114
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4115
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4116
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4117
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
  4118
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4119
	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
  4120
	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
  4121
	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
  4122
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4123
	/* 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
  4124
	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
  4125
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4126
	/* 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
  4127
	 * 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
  4128
	 * 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
  4129
	 * 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
  4130
	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
  4131
		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
  4132
						&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
  4133
		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
  4134
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4135
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4136
	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
  4137
	                  &work_done, budget);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4138
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4139
	if (tx_cleaned)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4140
		work_done = budget;
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
	/* 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
  4143
	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
  4144
		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
  4145
			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
  4146
		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
  4147
		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
  4148
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4149
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4150
	return work_done;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4151
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4152
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4153
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4154
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4155
 * 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
  4156
 * @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
  4157
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4158
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4159
static bool
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4160
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
  4161
                   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
  4162
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4163
	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
  4164
	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
  4165
	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
  4166
	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
  4167
#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
  4168
	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
  4169
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4170
	bool cleaned = false;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4171
	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
  4172
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4173
	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
  4174
	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
  4175
	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
  4176
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4177
	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
  4178
		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
  4179
			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
  4180
			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
  4181
			cleaned = (i == eop);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4182
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4183
			if (cleaned) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4184
				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
  4185
				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
  4186
				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
  4187
				/* 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
  4188
				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
  4189
				            skb->len;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4190
				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
  4191
				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
  4192
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4193
			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
  4194
			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
  4195
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4196
			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
  4197
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4198
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4199
		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
  4200
		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
  4201
#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
  4202
#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
  4203
		/* 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
  4204
		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
  4205
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4206
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4207
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4208
	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
  4209
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4210
#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
  4211
	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
  4212
		     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
  4213
		/* 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
  4214
		 * 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
  4215
		 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4216
		smp_mb();
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4217
		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
  4218
			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
  4219
			++adapter->restart_queue;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4220
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4221
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4222
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4223
	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
  4224
		/* 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
  4225
		 * 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
  4226
		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
  4227
		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
  4228
		    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
  4229
		               (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
  4230
		    && !(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
  4231
		         E1000_STATUS_TXOFF)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4232
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4233
			/* 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
  4234
			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
  4235
					"  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
  4236
					"  TDH                  <%x>\n"
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4237
					"  TDT                  <%x>\n"
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4238
					"  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
  4239
					"  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
  4240
					"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
  4241
					"  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
  4242
					"  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
  4243
					"  jiffies              <%lx>\n"
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4244
					"  next_to_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
  4245
				(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
  4246
					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
  4247
				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
  4248
				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
  4249
				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
  4250
				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
  4251
				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
  4252
				eop,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4253
				jiffies,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4254
				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
  4255
			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
  4256
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4257
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4258
	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
  4259
	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
  4260
	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
  4261
	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
  4262
	return cleaned;
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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4266
 * 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
  4267
 * @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
  4268
 * @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
  4269
 * @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
  4270
 * @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
  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
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4274
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
  4275
		  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
  4276
		  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
  4277
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4278
	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
  4279
	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
  4280
	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
  4281
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4282
	/* 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
  4283
	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
  4284
	/* 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
  4285
	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
  4286
	/* 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
  4287
	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
  4288
		/* 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
  4289
		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
  4290
		return;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4291
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4292
	/* TCP/UDP Checksum 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
  4293
	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
  4294
		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
  4295
			return;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4296
	} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4297
		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
  4298
			return;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4299
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4300
	/* 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
  4301
	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
  4302
		/* 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
  4303
		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
  4304
	} 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
  4305
		/* 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
  4306
		/* 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
  4307
		 * 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
  4308
		 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4309
		__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
  4310
		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
  4311
		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
  4312
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4313
	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
  4314
}
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
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4317
 * 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
  4318
 * @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
  4319
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4320
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4321
static bool
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4322
#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
  4323
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
  4324
                   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
  4325
                   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
  4326
#else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4327
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
  4328
                   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
  4329
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4330
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4331
	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
  4332
	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
  4333
	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
  4334
	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
  4335
	unsigned long flags;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4336
	u32 length;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4337
	u8 last_byte;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4338
	unsigned int i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4339
	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
  4340
	bool cleaned = false;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4341
	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
  4342
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4343
	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
  4344
	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
  4345
	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
  4346
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4347
	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
  4348
		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
  4349
		u8 status;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4350
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4351
#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
  4352
		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
  4353
			break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4354
		(*work_done)++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4355
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4356
		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
  4357
		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
  4358
		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
  4359
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4360
		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
  4361
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4362
		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
  4363
		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
  4364
		prefetch(next_rxd);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4365
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4366
		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
  4367
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4368
		cleaned = true;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4369
		cleaned_count++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4370
		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
  4371
		                 buffer_info->dma,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4372
		                 buffer_info->length,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4373
		                 PCI_DMA_FROMDEVICE);
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
		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
  4376
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4377
		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
  4378
			/* 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
  4379
			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
  4380
				  " 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
  4381
			/* recycle */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4382
			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
  4383
			goto next_desc;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4384
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4385
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4386
		if (!adapter->ecdev &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4387
                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
  4388
			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
  4389
			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
  4390
			              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
  4391
				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
  4392
				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
  4393
				                       &adapter->stats,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4394
				                       length, skb->data);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4395
				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
  4396
				                       flags);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4397
				length--;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4398
			} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4399
				/* recycle */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4400
				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
  4401
				goto next_desc;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4402
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4403
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4404
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4405
		/* 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
  4406
		 * 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
  4407
		length -= 4;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4408
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4409
		/* 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
  4410
		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
  4411
		total_rx_packets++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4412
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4413
		/* 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
  4414
		 * 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
  4415
		 * 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
  4416
		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
  4417
			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
  4418
			    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
  4419
			if (new_skb) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4420
				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
  4421
				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
  4422
							       -NET_IP_ALIGN,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4423
							       (skb->data -
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4424
							        NET_IP_ALIGN),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4425
							       (length +
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4426
							        NET_IP_ALIGN));
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4427
				/* 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
  4428
				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
  4429
				skb = new_skb;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4430
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4431
			/* 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
  4432
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4433
		/* end copybreak code */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4434
		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
  4435
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4436
		/* Receive Checksum Offload */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4437
		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
  4438
				  (u32)(status) |
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4439
				  ((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
  4440
				  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
  4441
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4442
		if (adapter->ecdev) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4443
			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
  4444
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4445
			// 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
  4446
			// 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
  4447
			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
  4448
		} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4449
			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
  4450
#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
  4451
			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
  4452
			   	 (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
  4453
				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
  4454
							 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
  4455
							 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
  4456
			} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4457
				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
  4458
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4459
#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
  4460
			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
  4461
				    (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
  4462
				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
  4463
						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
  4464
						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
  4465
			} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4466
				netif_rx(skb);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4467
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4468
#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
  4469
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4470
		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
  4471
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4472
next_desc:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4473
		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
  4474
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4475
		/* 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
  4476
		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
  4477
			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
  4478
			cleaned_count = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4479
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4480
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4481
		/* use prefetched values */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4482
		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
  4483
		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
  4484
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4485
	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
  4486
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4487
	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
  4488
	if (cleaned_count)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4489
		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
  4490
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4491
	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
  4492
	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
  4493
	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
  4494
	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
  4495
	return cleaned;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4496
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4497
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4498
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4499
 * 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
  4500
 * @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
  4501
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4502
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4503
static bool
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4504
#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
  4505
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
  4506
                      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
  4507
                      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
  4508
#else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4509
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
  4510
                      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
  4511
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4512
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4513
	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
  4514
	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
  4515
	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
  4516
	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
  4517
	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
  4518
	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
  4519
	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
  4520
	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
  4521
	u32 length, staterr;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4522
	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
  4523
	bool cleaned = false;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4524
	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
  4525
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4526
	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
  4527
	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
  4528
	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
  4529
	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
  4530
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4531
	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
  4532
		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
  4533
		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
  4534
#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
  4535
		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
  4536
			break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4537
		(*work_done)++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4538
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4539
		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
  4540
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4541
		/* 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
  4542
		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
  4543
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4544
		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
  4545
		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
  4546
		prefetch(next_rxd);
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
		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
  4549
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4550
		cleaned = true;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4551
		cleaned_count++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4552
		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
  4553
				 buffer_info->length,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4554
				 PCI_DMA_FROMDEVICE);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4555
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4556
		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
  4557
			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
  4558
				  " 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
  4559
			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
  4560
			goto next_desc;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4561
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4562
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_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
  4564
			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
  4565
			goto next_desc;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4566
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4567
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4568
		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
  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(!length)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4571
			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
  4572
				  " 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
  4573
			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
  4574
			goto next_desc;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4575
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4576
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4577
		/* Good Receive */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4578
		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
  4579
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4580
		{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4581
		/* 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
  4582
		   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
  4583
		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
  4584
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4585
		/* 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
  4586
		 * 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
  4587
		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
  4588
			u8 *vaddr;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4589
			/* 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
  4590
			 * 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
  4591
			 * very long */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4592
			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
  4593
				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
  4594
				PAGE_SIZE,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4595
				PCI_DMA_FROMDEVICE);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4596
			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
  4597
			                    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
  4598
			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
  4599
			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
  4600
			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
  4601
				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
  4602
				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
  4603
			/* remove the CRC */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4604
			l1 -= 4;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4605
			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
  4606
			goto copydone;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4607
		} /* if */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4608
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4609
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4610
		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
  4611
			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
  4612
				break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4613
			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
  4614
					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
  4615
			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
  4616
			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
  4617
			                   length);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4618
			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
  4619
			skb->len += length;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4620
			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
  4621
			skb->truesize += length;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4622
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4623
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4624
		/* 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
  4625
		 * 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
  4626
		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
  4627
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4628
copydone:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4629
		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
  4630
		total_rx_packets++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4631
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4632
		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
  4633
				  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
  4634
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4635
		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
  4636
			   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
  4637
			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
  4638
		if (adapter->ecdev) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4639
			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
  4640
		} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4641
			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
  4642
#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
  4643
			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
  4644
				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
  4645
					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
  4646
					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
  4647
			} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4648
				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
  4649
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4650
#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
  4651
			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
  4652
				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
  4653
					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
  4654
					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
  4655
			} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4656
				netif_rx(skb);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4657
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4658
#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
  4659
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4660
		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
  4661
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4662
next_desc:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4663
		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
  4664
		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
  4665
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4666
		/* 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
  4667
		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
  4668
			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
  4669
			cleaned_count = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4670
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4671
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4672
		/* use prefetched values */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4673
		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
  4674
		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
  4675
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4676
		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
  4677
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4678
	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
  4679
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4680
	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
  4681
	if (cleaned_count)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4682
		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
  4683
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4684
	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
  4685
	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
  4686
	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
  4687
	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
  4688
	return cleaned;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4689
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4690
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4691
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4692
 * 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
  4693
 * @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
  4694
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4695
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4696
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4697
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
  4698
                       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
  4699
		       int cleaned_count)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4700
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4701
	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
  4702
	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
  4703
	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
  4704
	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
  4705
	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
  4706
	unsigned int i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4707
	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
  4708
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4709
	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
  4710
	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
  4711
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4712
	while (cleaned_count--) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4713
		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
  4714
		if (skb) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4715
			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
  4716
			goto map_skb;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4717
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4718
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4719
		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
  4720
		if (unlikely(!skb)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4721
			/* 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
  4722
			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
  4723
			break;
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
		/* 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
  4727
		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
  4728
			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
  4729
			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
  4730
					     "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
  4731
			/* 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
  4732
			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
  4733
			/* 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
  4734
			if (!skb) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4735
				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
  4736
				break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4737
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4738
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4739
			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
  4740
				/* give up */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4741
				dev_kfree_skb(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; /* 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
  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
			/* Use new allocation */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4747
			dev_kfree_skb(oldskb);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4748
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4749
		/* 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
  4750
		 * 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
  4751
		 * 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
  4752
		 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4753
		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
  4754
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4755
		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
  4756
		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
  4757
map_skb:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4758
		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
  4759
						  skb->data,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4760
						  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
  4761
						  PCI_DMA_FROMDEVICE);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4762
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4763
		/* 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
  4764
		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
  4765
					(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
  4766
					adapter->rx_buffer_len)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4767
			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
  4768
				"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
  4769
				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
  4770
				(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
  4771
			if (!adapter->ecdev) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4772
				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
  4773
				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
  4774
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4775
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4776
			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
  4777
					 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
  4778
					 PCI_DMA_FROMDEVICE);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4779
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4780
			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
  4781
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4782
		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
  4783
		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
  4784
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4785
		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
  4786
			i = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4787
		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
  4788
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4789
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4790
	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
  4791
		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
  4792
		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
  4793
			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
  4794
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4795
		/* 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
  4796
		 * 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
  4797
		 * 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
  4798
		 * 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
  4799
		wmb();
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4800
		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
  4801
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4802
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4803
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4804
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4805
 * 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
  4806
 * @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
  4807
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4808
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4809
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4810
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
  4811
                          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
  4812
			  int cleaned_count)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4813
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4814
	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
  4815
	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
  4816
	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
  4817
	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
  4818
	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
  4819
	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
  4820
	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
  4821
	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
  4822
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4823
	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
  4824
	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
  4825
	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
  4826
	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
  4827
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4828
	while (cleaned_count--) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4829
		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
  4830
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4831
		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
  4832
			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
  4833
				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
  4834
					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
  4835
						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
  4836
					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
  4837
						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
  4838
						goto no_buffers;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4839
					}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4840
					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
  4841
						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
  4842
							    ps_page->ps_page[j],
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4843
							    0, PAGE_SIZE,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4844
							    PCI_DMA_FROMDEVICE);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4845
				}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4846
				/* 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
  4847
				 * 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
  4848
				 * this info.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4849
				 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4850
				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
  4851
				     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
  4852
			} else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4853
				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
  4854
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4855
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4856
		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
  4857
		                       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
  4858
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4859
		if (unlikely(!skb)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4860
			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
  4861
			break;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4864
		/* 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
  4865
		 * 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
  4866
		 * 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
  4867
		 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4868
		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
  4869
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4870
		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
  4871
		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
  4872
		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
  4873
						  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
  4874
						  PCI_DMA_FROMDEVICE);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4875
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4876
		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
  4877
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4878
		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
  4879
		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
  4880
		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
  4881
		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
  4882
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4883
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4884
no_buffers:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4885
	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
  4886
		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
  4887
		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
  4888
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4889
		/* 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
  4890
		 * 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
  4891
		 * 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
  4892
		 * 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
  4893
		wmb();
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4894
		/* 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
  4895
		 * 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
  4896
		 * twice as much.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4897
		 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4898
		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
  4899
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4900
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4901
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4902
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4903
 * 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
  4904
 * @adapter:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4905
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4906
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4907
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4908
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
  4909
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4910
	u16 phy_status;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4911
	u16 phy_ctrl;
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
	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
  4914
	   !(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
  4915
		return;
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
	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
  4918
		/* 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
  4919
		 * 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
  4920
		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
  4921
		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
  4922
		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
  4923
		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
  4924
		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
  4925
		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
  4926
			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
  4927
			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
  4928
					    phy_ctrl);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4929
			adapter->smartspeed++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4930
			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
  4931
			   !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
  4932
				   	       &phy_ctrl)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4933
				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
  4934
					     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
  4935
				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
  4936
						    phy_ctrl);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4937
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4938
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4939
		return;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4940
	} 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
  4941
		/* 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
  4942
		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
  4943
		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
  4944
		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
  4945
		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
  4946
		   !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
  4947
			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
  4948
				     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
  4949
			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
  4950
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4951
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4952
	/* 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
  4953
	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
  4954
		adapter->smartspeed = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4955
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4956
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4957
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4958
 * e1000_ioctl -
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4959
 * @netdev:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4960
 * @ifreq:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4961
 * @cmd:
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
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4965
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
  4966
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4967
	switch (cmd) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4968
	case SIOCGMIIPHY:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4969
	case SIOCGMIIREG:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4970
	case SIOCSMIIREG:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4971
		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
  4972
	default:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4973
		return -EOPNOTSUPP;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4974
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4975
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4976
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4977
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4978
 * e1000_mii_ioctl -
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4979
 * @netdev:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4980
 * @ifreq:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4981
 * @cmd:
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
static int
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(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
  4986
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4987
	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
  4988
	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
  4989
	int retval;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4990
	u16 mii_reg;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4991
	u16 spddplx;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4992
	unsigned long flags;
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
	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
  4995
		return -EOPNOTSUPP;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4996
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4997
	switch (cmd) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4998
	case SIOCGMIIPHY:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4999
		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
  5000
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5001
	case SIOCGMIIREG:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5002
		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
  5003
			return -EPERM;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5004
		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
  5005
		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
  5006
				   &data->val_out)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5007
			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
  5008
			return -EIO;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5009
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5010
		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
  5011
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5012
	case SIOCSMIIREG:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5013
		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
  5014
			return -EPERM;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5015
		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
  5016
			return -EFAULT;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5017
		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
  5018
		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
  5019
		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
  5020
					mii_reg)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5021
			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
  5022
			return -EIO;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5023
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5024
		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
  5025
		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
  5026
			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
  5027
			case PHY_CTRL:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5028
				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
  5029
					break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5030
				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
  5031
					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
  5032
					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
  5033
				} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5034
					if (mii_reg & 0x40)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5035
						spddplx = SPEED_1000;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5036
					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
  5037
						spddplx = SPEED_100;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5038
					else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5039
						spddplx = SPEED_10;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5040
					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
  5041
						   ? DUPLEX_FULL :
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5042
						   DUPLEX_HALF;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5043
					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
  5044
								    spddplx);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5045
					if (retval)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5046
						return retval;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5047
				}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5048
				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
  5049
					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
  5050
				else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5051
					e1000_reset(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5052
				break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5053
			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
  5054
			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
  5055
				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
  5056
					return -EIO;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5057
				break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5058
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5059
		} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5060
			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
  5061
			case PHY_CTRL:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5062
				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
  5063
					break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5064
				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
  5065
					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
  5066
				else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5067
					e1000_reset(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5068
				break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5069
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5070
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5071
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5072
	default:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5073
		return -EOPNOTSUPP;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5074
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5075
	return E1000_SUCCESS;
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
void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5079
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
  5080
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5081
	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
  5082
	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
  5083
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5084
	if (ret_val)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5085
		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
  5086
}
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
void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5089
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
  5090
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5091
	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
  5092
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5093
	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
  5094
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5095
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5096
int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5097
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
  5098
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5099
	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
  5100
	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
  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
void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5104
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
  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
	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
  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
s32
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5111
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
  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
    u16 cap_offset;
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
    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
  5117
    if (!cap_offset)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5118
        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
  5119
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5120
    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
  5121
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5122
    return E1000_SUCCESS;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5123
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5124
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5125
void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5126
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
  5127
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5128
	outl(value, port);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5129
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5130
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5131
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5132
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
  5133
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5134
	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
  5135
	u32 ctrl, rctl;
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
	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
  5138
		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
  5139
	adapter->vlgrp = 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
	if (grp) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5142
		/* 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
  5143
		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
  5144
		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
  5145
		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
  5146
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5147
		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
  5148
			/* 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
  5149
			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
  5150
			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
  5151
			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
  5152
			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
  5153
			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
  5154
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5155
	} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5156
		/* 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
  5157
		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
  5158
		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
  5159
		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
  5160
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5161
		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
  5162
			/* disable VLAN filtering */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5163
			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
  5164
			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
  5165
			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
  5166
			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
  5167
			    (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
  5168
				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
  5169
				                       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
  5170
				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
  5171
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5172
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5173
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5174
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5175
	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
  5176
		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
  5177
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5178
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5179
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5180
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
  5181
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5182
	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
  5183
	u32 vfta, index;
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
	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
  5186
	     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
  5187
	    (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
  5188
		return;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5189
	/* 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
  5190
	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
  5191
	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
  5192
	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
  5193
	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
  5194
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5195
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5196
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5197
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
  5198
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5199
	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
  5200
	u32 vfta, index;
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
	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
  5203
		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
  5204
	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
  5205
	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
  5206
		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
  5207
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5208
	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
  5209
	     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
  5210
	    (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
  5211
		/* 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
  5212
		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
  5213
		return;
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
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5216
	/* 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
  5217
	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
  5218
	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
  5219
	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
  5220
	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
  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
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5224
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
  5225
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5226
	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
  5227
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5228
	if (adapter->vlgrp) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5229
		u16 vid;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5230
		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
  5231
			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
  5232
				continue;
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_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
  5234
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5235
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5236
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5237
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5238
int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5239
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
  5240
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5241
	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
  5242
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5243
	/* 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
  5244
	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
  5245
		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
  5246
		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
  5247
		return -EINVAL;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5248
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5249
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5250
	switch (spddplx) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5251
	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
  5252
		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
  5253
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5254
	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
  5255
		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
  5256
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5257
	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
  5258
		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
  5259
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5260
	case SPEED_100 + DUPLEX_FULL:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5261
		adapter->hw.forced_speed_duplex = e1000_100_full;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5262
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5263
	case SPEED_1000 + DUPLEX_FULL:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5264
		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
  5265
		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
  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_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
  5268
	default:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5269
		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
  5270
		return -EINVAL;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5271
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5272
	return 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5273
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5274
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5275
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5276
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
  5277
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5278
	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
  5279
	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
  5280
	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
  5281
	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
  5282
#ifdef CONFIG_PM
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5283
	int retval = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5284
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5285
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5286
	if (adapter->ecdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5287
		return -EBUSY;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5288
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5289
	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
  5290
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5291
	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
  5292
		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
  5293
		e1000_down(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5294
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5295
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5296
#ifdef CONFIG_PM
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5297
	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
  5298
	if (retval)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5299
		return retval;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5300
#endif
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
	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
  5303
	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
  5304
		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
  5305
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5306
	if (wufc) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5307
		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
  5308
		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
  5309
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5310
		/* 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
  5311
		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
  5312
			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
  5313
			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
  5314
			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
  5315
		}
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
		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
  5318
			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
  5319
			/* 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
  5320
			#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
  5321
			/* 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
  5322
			#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
  5323
			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
  5324
				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
  5325
			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
  5326
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5327
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5328
		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
  5329
		   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
  5330
			/* 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
  5331
			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
  5332
			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
  5333
			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
  5334
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5335
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5336
		/* 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
  5337
		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
  5338
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5339
		E1000_WRITE_REG(&adapter->hw, 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
  5340
		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
  5341
		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
  5342
		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
  5343
	} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5344
		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
  5345
		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
  5346
		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
  5347
		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
  5348
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5349
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5350
	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
  5351
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5352
	/* 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
  5353
	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
  5354
		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
  5355
		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
  5356
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5357
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5358
	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
  5359
		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
  5360
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5361
	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
  5362
		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
  5363
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5364
	/* 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
  5365
	 * 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
  5366
	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
  5367
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5368
	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
  5369
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5370
	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
  5371
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5372
	return 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5373
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5374
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5375
#ifdef CONFIG_PM
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5376
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5377
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
  5378
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5379
	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
  5380
	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
  5381
	u32 err;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5382
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5383
	if (adapter->ecdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5384
		return -EBUSY;
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
	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
  5387
	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
  5388
	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
  5389
		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
  5390
		return err;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5391
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5392
	pci_set_master(pdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5393
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5394
	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
  5395
	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
  5396
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5397
	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
  5398
		return err;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5399
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5400
	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
  5401
	e1000_reset(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5402
	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
  5403
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5404
	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
  5405
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5406
	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
  5407
		e1000_up(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5408
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5409
	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
  5410
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5411
	/* 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
  5412
	 * 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
  5413
	 * 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
  5414
	 * of the driver. */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5415
	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
  5416
	    !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
  5417
		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
  5418
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5419
	return 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5420
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5421
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5422
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5423
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
  5424
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5425
	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
  5426
}
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
#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
  5429
/*
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5430
 * 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
  5431
 * 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
  5432
 * 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
  5433
 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5434
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5435
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
  5436
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5437
	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
  5438
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5439
	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
  5440
	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
  5441
	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
  5442
#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
  5443
	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
  5444
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5445
	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
  5446
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5447
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5448
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5449
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5450
 * 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
  5451
 * @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
  5452
 * @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
  5453
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5454
 * 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
  5455
 * 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
  5456
 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5457
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
  5458
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5459
	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
  5460
	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
  5461
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5462
	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
  5463
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5464
	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
  5465
		e1000_down(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5466
	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
  5467
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5468
	/* 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
  5469
	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
  5470
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5471
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5472
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5473
 * 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
  5474
 * @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
  5475
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5476
 * 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
  5477
 * 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
  5478
 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5479
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
  5480
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5481
	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
  5482
	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
  5483
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5484
	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
  5485
		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
  5486
		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
  5487
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5488
	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
  5489
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5490
	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
  5491
	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
  5492
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5493
	e1000_reset(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5494
	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
  5495
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5496
	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
  5497
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5498
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5499
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5500
 * 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
  5501
 * @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
  5502
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5503
 * 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
  5504
 * 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
  5505
 * 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
  5506
 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5507
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
  5508
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5509
	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
  5510
	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
  5511
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5512
	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
  5513
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5514
	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
  5515
		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
  5516
			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
  5517
			return;
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
	}
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
	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
  5522
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5523
	/* 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
  5524
	 * 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
  5525
	 * 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
  5526
	 * of the driver. */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5527
	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
  5528
	    !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
  5529
		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
  5530
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5531
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5532
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5533
/* e1000_main.c */