devices/e1000e/netdev-2.6.35-ethercat.c
author Florian Pose <fp@igh-essen.com>
Fri, 06 Apr 2012 23:30:35 +0200
branchredundancy
changeset 2373 593272e5a169
parent 2359 dce13f854817
child 2421 bc2d4bf9cbe5
child 2589 2b9c78543663
permissions -rw-r--r--
Clarified fields of ec_master_state_t in redundancy case.
2359
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/*******************************************************************************
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
  Intel PRO/1000 Linux driver
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
  Copyright(c) 1999 - 2009 Intel Corporation.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     5
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     6
  This program is free software; you can redistribute it and/or modify it
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     7
  under the terms and conditions of the GNU General Public License,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
  version 2, as published by the Free Software Foundation.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     9
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    10
  This program is distributed in the hope it will be useful, but WITHOUT
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    11
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    12
  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
  more details.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    14
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    15
  You should have received a copy of the GNU General Public License along with
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    16
  this program; if not, write to the Free Software Foundation, Inc.,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    17
  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    18
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    19
  The full GNU General Public License is included in this distribution in
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    20
  the file called "COPYING".
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    21
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    22
  Contact Information:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    23
  Linux NICS <linux.nics@intel.com>
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    24
  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    25
  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    26
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    27
*******************************************************************************/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    28
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
#include <linux/module.h>
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
#include <linux/types.h>
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
#include <linux/init.h>
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
#include <linux/pci.h>
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
#include <linux/vmalloc.h>
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
#include <linux/pagemap.h>
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
#include <linux/delay.h>
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
#include <linux/netdevice.h>
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    39
#include <linux/tcp.h>
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
#include <linux/ipv6.h>
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
#include <linux/slab.h>
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
#include <net/checksum.h>
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
#include <net/ip6_checksum.h>
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
#include <linux/mii.h>
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
#include <linux/ethtool.h>
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
#include <linux/if_vlan.h>
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
#include <linux/cpu.h>
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    48
#include <linux/smp.h>
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    49
#include <linux/pm_qos_params.h>
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    50
#include <linux/pm_runtime.h>
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    51
#include <linux/aer.h>
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    52
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    53
#include "e1000-2.6.35-ethercat.h"
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    54
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    55
#define DRV_VERSION "1.0.2-k4 (EtherCAT)"
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    56
char e1000e_driver_name[] = "ec_e1000e";
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    57
const char e1000e_driver_version[] = DRV_VERSION;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    58
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    59
static const struct e1000_info *e1000_info_tbl[] = {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    60
	[board_82571]		= &e1000_82571_info,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    61
	[board_82572]		= &e1000_82572_info,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    62
	[board_82573]		= &e1000_82573_info,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    63
	[board_82574]		= &e1000_82574_info,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    64
	[board_82583]		= &e1000_82583_info,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    65
	[board_80003es2lan]	= &e1000_es2_info,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    66
	[board_ich8lan]		= &e1000_ich8_info,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    67
	[board_ich9lan]		= &e1000_ich9_info,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    68
	[board_ich10lan]	= &e1000_ich10_info,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    69
	[board_pchlan]		= &e1000_pch_info,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    70
};
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    71
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    72
struct e1000_reg_info {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    73
	u32 ofs;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    74
	char *name;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    75
};
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    76
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    77
#define E1000_RDFH	0x02410 /* Rx Data FIFO Head - RW */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    78
#define E1000_RDFT	0x02418 /* Rx Data FIFO Tail - RW */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    79
#define E1000_RDFHS	0x02420 /* Rx Data FIFO Head Saved - RW */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    80
#define E1000_RDFTS	0x02428 /* Rx Data FIFO Tail Saved - RW */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    81
#define E1000_RDFPC	0x02430 /* Rx Data FIFO Packet Count - RW */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    82
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    83
#define E1000_TDFH	0x03410 /* Tx Data FIFO Head - RW */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    84
#define E1000_TDFT	0x03418 /* Tx Data FIFO Tail - RW */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    85
#define E1000_TDFHS	0x03420 /* Tx Data FIFO Head Saved - RW */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    86
#define E1000_TDFTS	0x03428 /* Tx Data FIFO Tail Saved - RW */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    87
#define E1000_TDFPC	0x03430 /* Tx Data FIFO Packet Count - RW */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    88
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    89
static const struct e1000_reg_info e1000_reg_info_tbl[] = {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    90
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    91
	/* General Registers */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    92
	{E1000_CTRL, "CTRL"},
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    93
	{E1000_STATUS, "STATUS"},
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    94
	{E1000_CTRL_EXT, "CTRL_EXT"},
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    95
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    96
	/* Interrupt Registers */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    97
	{E1000_ICR, "ICR"},
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    98
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    99
	/* RX Registers */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   100
	{E1000_RCTL, "RCTL"},
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   101
	{E1000_RDLEN, "RDLEN"},
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   102
	{E1000_RDH, "RDH"},
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   103
	{E1000_RDT, "RDT"},
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   104
	{E1000_RDTR, "RDTR"},
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   105
	{E1000_RXDCTL(0), "RXDCTL"},
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   106
	{E1000_ERT, "ERT"},
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   107
	{E1000_RDBAL, "RDBAL"},
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   108
	{E1000_RDBAH, "RDBAH"},
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   109
	{E1000_RDFH, "RDFH"},
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   110
	{E1000_RDFT, "RDFT"},
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   111
	{E1000_RDFHS, "RDFHS"},
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   112
	{E1000_RDFTS, "RDFTS"},
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   113
	{E1000_RDFPC, "RDFPC"},
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   114
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   115
	/* TX Registers */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   116
	{E1000_TCTL, "TCTL"},
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   117
	{E1000_TDBAL, "TDBAL"},
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   118
	{E1000_TDBAH, "TDBAH"},
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   119
	{E1000_TDLEN, "TDLEN"},
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   120
	{E1000_TDH, "TDH"},
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   121
	{E1000_TDT, "TDT"},
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   122
	{E1000_TIDV, "TIDV"},
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   123
	{E1000_TXDCTL(0), "TXDCTL"},
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   124
	{E1000_TADV, "TADV"},
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   125
	{E1000_TARC(0), "TARC"},
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   126
	{E1000_TDFH, "TDFH"},
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   127
	{E1000_TDFT, "TDFT"},
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   128
	{E1000_TDFHS, "TDFHS"},
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   129
	{E1000_TDFTS, "TDFTS"},
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   130
	{E1000_TDFPC, "TDFPC"},
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   131
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   132
	/* List Terminator */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   133
	{}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   134
};
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   135
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   136
/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   137
 * e1000_regdump - register printout routine
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   138
 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   139
static void e1000_regdump(struct e1000_hw *hw, struct e1000_reg_info *reginfo)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   140
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   141
	int n = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   142
	char rname[16];
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   143
	u32 regs[8];
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   144
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   145
	switch (reginfo->ofs) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   146
	case E1000_RXDCTL(0):
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   147
		for (n = 0; n < 2; n++)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   148
			regs[n] = __er32(hw, E1000_RXDCTL(n));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   149
		break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   150
	case E1000_TXDCTL(0):
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   151
		for (n = 0; n < 2; n++)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   152
			regs[n] = __er32(hw, E1000_TXDCTL(n));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   153
		break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   154
	case E1000_TARC(0):
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   155
		for (n = 0; n < 2; n++)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   156
			regs[n] = __er32(hw, E1000_TARC(n));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   157
		break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   158
	default:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   159
		printk(KERN_INFO "%-15s %08x\n",
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   160
			reginfo->name, __er32(hw, reginfo->ofs));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   161
		return;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   162
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   163
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   164
	snprintf(rname, 16, "%s%s", reginfo->name, "[0-1]");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   165
	printk(KERN_INFO "%-15s ", rname);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   166
	for (n = 0; n < 2; n++)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   167
		printk(KERN_CONT "%08x ", regs[n]);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   168
	printk(KERN_CONT "\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   169
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   170
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   171
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   172
/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   173
 * e1000e_dump - Print registers, tx-ring and rx-ring
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   174
 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   175
static void e1000e_dump(struct e1000_adapter *adapter)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   176
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   177
	struct net_device *netdev = adapter->netdev;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   178
	struct e1000_hw *hw = &adapter->hw;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   179
	struct e1000_reg_info *reginfo;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   180
	struct e1000_ring *tx_ring = adapter->tx_ring;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   181
	struct e1000_tx_desc *tx_desc;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   182
	struct my_u0 { u64 a; u64 b; } *u0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   183
	struct e1000_buffer *buffer_info;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   184
	struct e1000_ring *rx_ring = adapter->rx_ring;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   185
	union e1000_rx_desc_packet_split *rx_desc_ps;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   186
	struct e1000_rx_desc *rx_desc;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   187
	struct my_u1 { u64 a; u64 b; u64 c; u64 d; } *u1;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   188
	u32 staterr;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   189
	int i = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   190
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   191
	if (!netif_msg_hw(adapter))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   192
		return;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   193
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   194
	/* Print netdevice Info */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   195
	if (netdev) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   196
		dev_info(&adapter->pdev->dev, "Net device Info\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   197
		printk(KERN_INFO "Device Name     state            "
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   198
			"trans_start      last_rx\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   199
		printk(KERN_INFO "%-15s %016lX %016lX %016lX\n",
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   200
			netdev->name,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   201
			netdev->state,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   202
			netdev->trans_start,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   203
			netdev->last_rx);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   204
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   205
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   206
	/* Print Registers */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   207
	dev_info(&adapter->pdev->dev, "Register Dump\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   208
	printk(KERN_INFO " Register Name   Value\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   209
	for (reginfo = (struct e1000_reg_info *)e1000_reg_info_tbl;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   210
	     reginfo->name; reginfo++) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   211
		e1000_regdump(hw, reginfo);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   212
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   213
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   214
	/* Print TX Ring Summary */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   215
	if (!netdev || !netif_running(netdev))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   216
		goto exit;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   217
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   218
	dev_info(&adapter->pdev->dev, "TX Rings Summary\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   219
	printk(KERN_INFO "Queue [NTU] [NTC] [bi(ntc)->dma  ]"
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   220
		" leng ntw timestamp\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   221
	buffer_info = &tx_ring->buffer_info[tx_ring->next_to_clean];
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   222
	printk(KERN_INFO " %5d %5X %5X %016llX %04X %3X %016llX\n",
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   223
		0, tx_ring->next_to_use, tx_ring->next_to_clean,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   224
		(u64)buffer_info->dma,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   225
		buffer_info->length,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   226
		buffer_info->next_to_watch,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   227
		(u64)buffer_info->time_stamp);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   228
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   229
	/* Print TX Rings */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   230
	if (!netif_msg_tx_done(adapter))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   231
		goto rx_ring_summary;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   232
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   233
	dev_info(&adapter->pdev->dev, "TX Rings Dump\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   234
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   235
	/* Transmit Descriptor Formats - DEXT[29] is 0 (Legacy) or 1 (Extended)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   236
	 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   237
	 * Legacy Transmit Descriptor
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   238
	 *   +--------------------------------------------------------------+
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   239
	 * 0 |         Buffer Address [63:0] (Reserved on Write Back)       |
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   240
	 *   +--------------------------------------------------------------+
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   241
	 * 8 | Special  |    CSS     | Status |  CMD    |  CSO   |  Length  |
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   242
	 *   +--------------------------------------------------------------+
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   243
	 *   63       48 47        36 35    32 31     24 23    16 15        0
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   244
	 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   245
	 * Extended Context Descriptor (DTYP=0x0) for TSO or checksum offload
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   246
	 *   63      48 47    40 39       32 31             16 15    8 7      0
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   247
	 *   +----------------------------------------------------------------+
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   248
	 * 0 |  TUCSE  | TUCS0  |   TUCSS   |     IPCSE       | IPCS0 | IPCSS |
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   249
	 *   +----------------------------------------------------------------+
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   250
	 * 8 |   MSS   | HDRLEN | RSV | STA | TUCMD | DTYP |      PAYLEN      |
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   251
	 *   +----------------------------------------------------------------+
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   252
	 *   63      48 47    40 39 36 35 32 31   24 23  20 19                0
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   253
	 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   254
	 * Extended Data Descriptor (DTYP=0x1)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   255
	 *   +----------------------------------------------------------------+
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   256
	 * 0 |                     Buffer Address [63:0]                      |
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   257
	 *   +----------------------------------------------------------------+
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   258
	 * 8 | VLAN tag |  POPTS  | Rsvd | Status | Command | DTYP |  DTALEN  |
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   259
	 *   +----------------------------------------------------------------+
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   260
	 *   63       48 47     40 39  36 35    32 31     24 23  20 19        0
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   261
	 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   262
	printk(KERN_INFO "Tl[desc]     [address 63:0  ] [SpeCssSCmCsLen]"
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   263
		" [bi->dma       ] leng  ntw timestamp        bi->skb "
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   264
		"<-- Legacy format\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   265
	printk(KERN_INFO "Tc[desc]     [Ce CoCsIpceCoS] [MssHlRSCm0Plen]"
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   266
		" [bi->dma       ] leng  ntw timestamp        bi->skb "
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   267
		"<-- Ext Context format\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   268
	printk(KERN_INFO "Td[desc]     [address 63:0  ] [VlaPoRSCm1Dlen]"
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   269
		" [bi->dma       ] leng  ntw timestamp        bi->skb "
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   270
		"<-- Ext Data format\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   271
	for (i = 0; tx_ring->desc && (i < tx_ring->count); i++) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   272
		tx_desc = E1000_TX_DESC(*tx_ring, i);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   273
		buffer_info = &tx_ring->buffer_info[i];
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   274
		u0 = (struct my_u0 *)tx_desc;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   275
		printk(KERN_INFO "T%c[0x%03X]    %016llX %016llX %016llX "
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   276
			"%04X  %3X %016llX %p",
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   277
		       (!(le64_to_cpu(u0->b) & (1<<29)) ? 'l' :
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   278
			((le64_to_cpu(u0->b) & (1<<20)) ? 'd' : 'c')), i,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   279
		       le64_to_cpu(u0->a), le64_to_cpu(u0->b),
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   280
		       (u64)buffer_info->dma, buffer_info->length,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   281
		       buffer_info->next_to_watch, (u64)buffer_info->time_stamp,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   282
		       buffer_info->skb);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   283
		if (i == tx_ring->next_to_use && i == tx_ring->next_to_clean)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   284
			printk(KERN_CONT " NTC/U\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   285
		else if (i == tx_ring->next_to_use)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   286
			printk(KERN_CONT " NTU\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   287
		else if (i == tx_ring->next_to_clean)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   288
			printk(KERN_CONT " NTC\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   289
		else
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   290
			printk(KERN_CONT "\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   291
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   292
		if (netif_msg_pktdata(adapter) && buffer_info->dma != 0)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   293
			print_hex_dump(KERN_INFO, "", DUMP_PREFIX_ADDRESS,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   294
					16, 1, phys_to_virt(buffer_info->dma),
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   295
					buffer_info->length, true);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   296
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   297
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   298
	/* Print RX Rings Summary */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   299
rx_ring_summary:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   300
	dev_info(&adapter->pdev->dev, "RX Rings Summary\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   301
	printk(KERN_INFO "Queue [NTU] [NTC]\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   302
	printk(KERN_INFO " %5d %5X %5X\n", 0,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   303
		rx_ring->next_to_use, rx_ring->next_to_clean);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   304
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   305
	/* Print RX Rings */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   306
	if (!netif_msg_rx_status(adapter))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   307
		goto exit;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   308
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   309
	dev_info(&adapter->pdev->dev, "RX Rings Dump\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   310
	switch (adapter->rx_ps_pages) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   311
	case 1:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   312
	case 2:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   313
	case 3:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   314
		/* [Extended] Packet Split Receive Descriptor Format
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   315
		 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   316
		 *    +-----------------------------------------------------+
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   317
		 *  0 |                Buffer Address 0 [63:0]              |
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   318
		 *    +-----------------------------------------------------+
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   319
		 *  8 |                Buffer Address 1 [63:0]              |
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   320
		 *    +-----------------------------------------------------+
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   321
		 * 16 |                Buffer Address 2 [63:0]              |
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   322
		 *    +-----------------------------------------------------+
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   323
		 * 24 |                Buffer Address 3 [63:0]              |
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   324
		 *    +-----------------------------------------------------+
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   325
		 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   326
		printk(KERN_INFO "R  [desc]      [buffer 0 63:0 ] "
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   327
			"[buffer 1 63:0 ] "
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   328
		       "[buffer 2 63:0 ] [buffer 3 63:0 ] [bi->dma       ] "
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   329
		       "[bi->skb] <-- Ext Pkt Split format\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   330
		/* [Extended] Receive Descriptor (Write-Back) Format
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   331
		 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   332
		 *   63       48 47    32 31     13 12    8 7    4 3        0
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   333
		 *   +------------------------------------------------------+
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   334
		 * 0 | Packet   | IP     |  Rsvd   | MRQ   | Rsvd | MRQ RSS |
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   335
		 *   | Checksum | Ident  |         | Queue |      |  Type   |
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   336
		 *   +------------------------------------------------------+
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   337
		 * 8 | VLAN Tag | Length | Extended Error | Extended Status |
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   338
		 *   +------------------------------------------------------+
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   339
		 *   63       48 47    32 31            20 19               0
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   340
		 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   341
		printk(KERN_INFO "RWB[desc]      [ck ipid mrqhsh] "
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   342
			"[vl   l0 ee  es] "
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   343
		       "[ l3  l2  l1 hs] [reserved      ] ---------------- "
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   344
		       "[bi->skb] <-- Ext Rx Write-Back format\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   345
		for (i = 0; i < rx_ring->count; i++) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   346
			buffer_info = &rx_ring->buffer_info[i];
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   347
			rx_desc_ps = E1000_RX_DESC_PS(*rx_ring, i);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   348
			u1 = (struct my_u1 *)rx_desc_ps;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   349
			staterr =
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   350
				le32_to_cpu(rx_desc_ps->wb.middle.status_error);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   351
			if (staterr & E1000_RXD_STAT_DD) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   352
				/* Descriptor Done */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   353
				printk(KERN_INFO "RWB[0x%03X]     %016llX "
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   354
					"%016llX %016llX %016llX "
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   355
					"---------------- %p", i,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   356
					le64_to_cpu(u1->a),
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   357
					le64_to_cpu(u1->b),
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   358
					le64_to_cpu(u1->c),
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   359
					le64_to_cpu(u1->d),
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   360
					buffer_info->skb);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   361
			} else {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   362
				printk(KERN_INFO "R  [0x%03X]     %016llX "
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   363
					"%016llX %016llX %016llX %016llX %p", i,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   364
					le64_to_cpu(u1->a),
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   365
					le64_to_cpu(u1->b),
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   366
					le64_to_cpu(u1->c),
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   367
					le64_to_cpu(u1->d),
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   368
					(u64)buffer_info->dma,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   369
					buffer_info->skb);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   370
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   371
				if (netif_msg_pktdata(adapter))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   372
					print_hex_dump(KERN_INFO, "",
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   373
						DUMP_PREFIX_ADDRESS, 16, 1,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   374
						phys_to_virt(buffer_info->dma),
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   375
						adapter->rx_ps_bsize0, true);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   376
			}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   377
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   378
			if (i == rx_ring->next_to_use)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   379
				printk(KERN_CONT " NTU\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   380
			else if (i == rx_ring->next_to_clean)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   381
				printk(KERN_CONT " NTC\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   382
			else
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   383
				printk(KERN_CONT "\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   384
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   385
		break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   386
	default:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   387
	case 0:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   388
		/* Legacy Receive Descriptor Format
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   389
		 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   390
		 * +-----------------------------------------------------+
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   391
		 * |                Buffer Address [63:0]                |
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   392
		 * +-----------------------------------------------------+
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   393
		 * | VLAN Tag | Errors | Status 0 | Packet csum | Length |
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   394
		 * +-----------------------------------------------------+
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   395
		 * 63       48 47    40 39      32 31         16 15      0
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   396
		 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   397
		printk(KERN_INFO "Rl[desc]     [address 63:0  ] "
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   398
			"[vl er S cks ln] [bi->dma       ] [bi->skb] "
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   399
			"<-- Legacy format\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   400
		for (i = 0; rx_ring->desc && (i < rx_ring->count); i++) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   401
			rx_desc = E1000_RX_DESC(*rx_ring, i);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   402
			buffer_info = &rx_ring->buffer_info[i];
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   403
			u0 = (struct my_u0 *)rx_desc;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   404
			printk(KERN_INFO "Rl[0x%03X]    %016llX %016llX "
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   405
				"%016llX %p",
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   406
				i, le64_to_cpu(u0->a), le64_to_cpu(u0->b),
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   407
				(u64)buffer_info->dma, buffer_info->skb);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   408
			if (i == rx_ring->next_to_use)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   409
				printk(KERN_CONT " NTU\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   410
			else if (i == rx_ring->next_to_clean)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   411
				printk(KERN_CONT " NTC\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   412
			else
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   413
				printk(KERN_CONT "\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   414
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   415
			if (netif_msg_pktdata(adapter))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   416
				print_hex_dump(KERN_INFO, "",
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   417
					DUMP_PREFIX_ADDRESS,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   418
					16, 1, phys_to_virt(buffer_info->dma),
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   419
					adapter->rx_buffer_len, true);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   420
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   421
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   422
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   423
exit:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   424
	return;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   425
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   426
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   427
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   428
 * e1000_desc_unused - calculate if we have unused descriptors
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   429
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   430
static int e1000_desc_unused(struct e1000_ring *ring)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   431
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   432
	if (ring->next_to_clean > ring->next_to_use)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   433
		return ring->next_to_clean - ring->next_to_use - 1;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   434
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   435
	return ring->count + ring->next_to_clean - ring->next_to_use - 1;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   436
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   437
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   438
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   439
 * e1000_receive_skb - helper function to handle Rx indications
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   440
 * @adapter: board private structure
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   441
 * @status: descriptor status field as written by hardware
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   442
 * @vlan: descriptor vlan field as written by hardware (no le/be conversion)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   443
 * @skb: pointer to sk_buff to be indicated to stack
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   444
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   445
static void e1000_receive_skb(struct e1000_adapter *adapter,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   446
			      struct net_device *netdev,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   447
			      struct sk_buff *skb,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   448
			      u8 status, __le16 vlan)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   449
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   450
	skb->protocol = eth_type_trans(skb, netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   451
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   452
	if (adapter->vlgrp && (status & E1000_RXD_STAT_VP))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   453
		vlan_gro_receive(&adapter->napi, adapter->vlgrp,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   454
				 le16_to_cpu(vlan), skb);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   455
	else
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   456
		napi_gro_receive(&adapter->napi, skb);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   457
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   458
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   459
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   460
 * e1000_rx_checksum - Receive Checksum Offload for 82543
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   461
 * @adapter:     board private structure
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   462
 * @status_err:  receive descriptor status and error fields
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   463
 * @csum:	receive descriptor csum field
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   464
 * @sk_buff:     socket buffer with received data
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   465
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   466
static void e1000_rx_checksum(struct e1000_adapter *adapter, u32 status_err,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   467
			      u32 csum, struct sk_buff *skb)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   468
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   469
	u16 status = (u16)status_err;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   470
	u8 errors = (u8)(status_err >> 24);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   471
	skb->ip_summed = CHECKSUM_NONE;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   472
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   473
	/* Ignore Checksum bit is set */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   474
	if (status & E1000_RXD_STAT_IXSM)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   475
		return;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   476
	/* TCP/UDP checksum error bit is set */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   477
	if (errors & E1000_RXD_ERR_TCPE) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   478
		/* let the stack verify checksum errors */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   479
		adapter->hw_csum_err++;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   480
		return;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   481
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   482
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   483
	/* TCP/UDP Checksum has not been calculated */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   484
	if (!(status & (E1000_RXD_STAT_TCPCS | E1000_RXD_STAT_UDPCS)))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   485
		return;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   486
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   487
	/* It must be a TCP or UDP packet with a valid checksum */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   488
	if (status & E1000_RXD_STAT_TCPCS) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   489
		/* TCP checksum is good */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   490
		skb->ip_summed = CHECKSUM_UNNECESSARY;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   491
	} else {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   492
		/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   493
		 * IP fragment with UDP payload
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   494
		 * Hardware complements the payload checksum, so we undo it
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   495
		 * and then put the value in host order for further stack use.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   496
		 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   497
		__sum16 sum = (__force __sum16)htons(csum);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   498
		skb->csum = csum_unfold(~sum);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   499
		skb->ip_summed = CHECKSUM_COMPLETE;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   500
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   501
	adapter->hw_csum_good++;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   502
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   503
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   504
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   505
 * e1000_alloc_rx_buffers - Replace used receive buffers; legacy & extended
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   506
 * @adapter: address of board private structure
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   507
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   508
static void e1000_alloc_rx_buffers(struct e1000_adapter *adapter,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   509
				   int cleaned_count)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   510
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   511
	struct net_device *netdev = adapter->netdev;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   512
	struct pci_dev *pdev = adapter->pdev;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   513
	struct e1000_ring *rx_ring = adapter->rx_ring;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   514
	struct e1000_rx_desc *rx_desc;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   515
	struct e1000_buffer *buffer_info;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   516
	struct sk_buff *skb;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   517
	unsigned int i;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   518
	unsigned int bufsz = adapter->rx_buffer_len;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   519
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   520
	i = rx_ring->next_to_use;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   521
	buffer_info = &rx_ring->buffer_info[i];
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   522
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   523
	while (cleaned_count--) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   524
		skb = buffer_info->skb;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   525
		if (skb) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   526
			skb_trim(skb, 0);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   527
			goto map_skb;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   528
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   529
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   530
		skb = netdev_alloc_skb_ip_align(netdev, bufsz);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   531
		if (!skb) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   532
			/* Better luck next round */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   533
			adapter->alloc_rx_buff_failed++;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   534
			break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   535
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   536
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   537
		buffer_info->skb = skb;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   538
map_skb:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   539
		buffer_info->dma = dma_map_single(&pdev->dev, skb->data,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   540
						  adapter->rx_buffer_len,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   541
						  DMA_FROM_DEVICE);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   542
		if (dma_mapping_error(&pdev->dev, buffer_info->dma)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   543
			dev_err(&pdev->dev, "RX DMA map failed\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   544
			adapter->rx_dma_failed++;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   545
			break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   546
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   547
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   548
		rx_desc = E1000_RX_DESC(*rx_ring, i);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   549
		rx_desc->buffer_addr = cpu_to_le64(buffer_info->dma);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   550
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   551
		if (unlikely(!(i & (E1000_RX_BUFFER_WRITE - 1)))) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   552
			/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   553
			 * Force memory writes to complete before letting h/w
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   554
			 * know there are new descriptors to fetch.  (Only
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   555
			 * applicable for weak-ordered memory model archs,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   556
			 * such as IA-64).
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   557
			 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   558
			wmb();
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   559
			writel(i, adapter->hw.hw_addr + rx_ring->tail);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   560
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   561
		i++;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   562
		if (i == rx_ring->count)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   563
			i = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   564
		buffer_info = &rx_ring->buffer_info[i];
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   565
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   566
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   567
	rx_ring->next_to_use = i;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   568
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   569
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   570
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   571
 * e1000_alloc_rx_buffers_ps - Replace used receive buffers; packet split
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   572
 * @adapter: address of board private structure
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   573
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   574
static void e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   575
				      int cleaned_count)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   576
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   577
	struct net_device *netdev = adapter->netdev;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   578
	struct pci_dev *pdev = adapter->pdev;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   579
	union e1000_rx_desc_packet_split *rx_desc;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   580
	struct e1000_ring *rx_ring = adapter->rx_ring;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   581
	struct e1000_buffer *buffer_info;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   582
	struct e1000_ps_page *ps_page;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   583
	struct sk_buff *skb;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   584
	unsigned int i, j;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   585
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   586
	i = rx_ring->next_to_use;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   587
	buffer_info = &rx_ring->buffer_info[i];
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   588
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   589
	while (cleaned_count--) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   590
		rx_desc = E1000_RX_DESC_PS(*rx_ring, i);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   591
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   592
		for (j = 0; j < PS_PAGE_BUFFERS; j++) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   593
			ps_page = &buffer_info->ps_pages[j];
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   594
			if (j >= adapter->rx_ps_pages) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   595
				/* all unused desc entries get hw null ptr */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   596
				rx_desc->read.buffer_addr[j+1] = ~cpu_to_le64(0);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   597
				continue;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   598
			}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   599
			if (!ps_page->page) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   600
				ps_page->page = alloc_page(GFP_ATOMIC);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   601
				if (!ps_page->page) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   602
					adapter->alloc_rx_buff_failed++;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   603
					goto no_buffers;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   604
				}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   605
				ps_page->dma = dma_map_page(&pdev->dev,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   606
							    ps_page->page,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   607
							    0, PAGE_SIZE,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   608
							    DMA_FROM_DEVICE);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   609
				if (dma_mapping_error(&pdev->dev,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   610
						      ps_page->dma)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   611
					dev_err(&adapter->pdev->dev,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   612
					  "RX DMA page map failed\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   613
					adapter->rx_dma_failed++;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   614
					goto no_buffers;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   615
				}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   616
			}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   617
			/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   618
			 * Refresh the desc even if buffer_addrs
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   619
			 * didn't change because each write-back
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   620
			 * erases this info.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   621
			 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   622
			rx_desc->read.buffer_addr[j+1] =
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   623
			     cpu_to_le64(ps_page->dma);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   624
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   625
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   626
		skb = netdev_alloc_skb_ip_align(netdev,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   627
						adapter->rx_ps_bsize0);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   628
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   629
		if (!skb) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   630
			adapter->alloc_rx_buff_failed++;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   631
			break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   632
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   633
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   634
		buffer_info->skb = skb;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   635
		buffer_info->dma = dma_map_single(&pdev->dev, skb->data,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   636
						  adapter->rx_ps_bsize0,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   637
						  DMA_FROM_DEVICE);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   638
		if (dma_mapping_error(&pdev->dev, buffer_info->dma)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   639
			dev_err(&pdev->dev, "RX DMA map failed\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   640
			adapter->rx_dma_failed++;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   641
			/* cleanup skb */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   642
			dev_kfree_skb_any(skb);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   643
			buffer_info->skb = NULL;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   644
			break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   645
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   646
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   647
		rx_desc->read.buffer_addr[0] = cpu_to_le64(buffer_info->dma);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   648
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   649
		if (unlikely(!(i & (E1000_RX_BUFFER_WRITE - 1)))) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   650
			/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   651
			 * Force memory writes to complete before letting h/w
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   652
			 * know there are new descriptors to fetch.  (Only
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   653
			 * applicable for weak-ordered memory model archs,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   654
			 * such as IA-64).
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   655
			 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   656
			wmb();
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   657
			writel(i<<1, adapter->hw.hw_addr + rx_ring->tail);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   658
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   659
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   660
		i++;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   661
		if (i == rx_ring->count)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   662
			i = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   663
		buffer_info = &rx_ring->buffer_info[i];
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   664
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   665
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   666
no_buffers:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   667
	rx_ring->next_to_use = i;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   668
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   669
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   670
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   671
 * e1000_alloc_jumbo_rx_buffers - Replace used jumbo receive buffers
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   672
 * @adapter: address of board private structure
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   673
 * @cleaned_count: number of buffers to allocate this pass
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   674
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   675
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   676
static void e1000_alloc_jumbo_rx_buffers(struct e1000_adapter *adapter,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   677
                                         int cleaned_count)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   678
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   679
	struct net_device *netdev = adapter->netdev;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   680
	struct pci_dev *pdev = adapter->pdev;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   681
	struct e1000_rx_desc *rx_desc;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   682
	struct e1000_ring *rx_ring = adapter->rx_ring;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   683
	struct e1000_buffer *buffer_info;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   684
	struct sk_buff *skb;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   685
	unsigned int i;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   686
	unsigned int bufsz = 256 - 16 /* for skb_reserve */;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   687
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   688
	i = rx_ring->next_to_use;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   689
	buffer_info = &rx_ring->buffer_info[i];
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   690
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   691
	while (cleaned_count--) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   692
		skb = buffer_info->skb;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   693
		if (skb) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   694
			skb_trim(skb, 0);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   695
			goto check_page;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   696
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   697
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   698
		skb = netdev_alloc_skb_ip_align(netdev, bufsz);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   699
		if (unlikely(!skb)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   700
			/* Better luck next round */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   701
			adapter->alloc_rx_buff_failed++;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   702
			break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   703
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   704
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   705
		buffer_info->skb = skb;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   706
check_page:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   707
		/* allocate a new page if necessary */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   708
		if (!buffer_info->page) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   709
			buffer_info->page = alloc_page(GFP_ATOMIC);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   710
			if (unlikely(!buffer_info->page)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   711
				adapter->alloc_rx_buff_failed++;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   712
				break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   713
			}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   714
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   715
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   716
		if (!buffer_info->dma)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   717
			buffer_info->dma = dma_map_page(&pdev->dev,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   718
			                                buffer_info->page, 0,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   719
			                                PAGE_SIZE,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   720
							DMA_FROM_DEVICE);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   721
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   722
		rx_desc = E1000_RX_DESC(*rx_ring, i);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   723
		rx_desc->buffer_addr = cpu_to_le64(buffer_info->dma);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   724
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   725
		if (unlikely(++i == rx_ring->count))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   726
			i = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   727
		buffer_info = &rx_ring->buffer_info[i];
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   728
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   729
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   730
	if (likely(rx_ring->next_to_use != i)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   731
		rx_ring->next_to_use = i;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   732
		if (unlikely(i-- == 0))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   733
			i = (rx_ring->count - 1);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   734
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   735
		/* Force memory writes to complete before letting h/w
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   736
		 * know there are new descriptors to fetch.  (Only
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   737
		 * applicable for weak-ordered memory model archs,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   738
		 * such as IA-64). */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   739
		wmb();
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   740
		writel(i, adapter->hw.hw_addr + rx_ring->tail);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   741
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   742
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   743
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   744
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   745
 * e1000_clean_rx_irq - Send received data up the network stack; legacy
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   746
 * @adapter: board private structure
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   747
 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   748
 * the return value indicates whether actual cleaning was done, there
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   749
 * is no guarantee that everything was cleaned
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   750
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   751
static bool e1000_clean_rx_irq(struct e1000_adapter *adapter,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   752
			       int *work_done, int work_to_do)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   753
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   754
	struct net_device *netdev = adapter->netdev;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   755
	struct pci_dev *pdev = adapter->pdev;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   756
	struct e1000_hw *hw = &adapter->hw;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   757
	struct e1000_ring *rx_ring = adapter->rx_ring;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   758
	struct e1000_rx_desc *rx_desc, *next_rxd;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   759
	struct e1000_buffer *buffer_info, *next_buffer;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   760
	u32 length;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   761
	unsigned int i;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   762
	int cleaned_count = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   763
	bool cleaned = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   764
	unsigned int total_rx_bytes = 0, total_rx_packets = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   765
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   766
	i = rx_ring->next_to_clean;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   767
	rx_desc = E1000_RX_DESC(*rx_ring, i);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   768
	buffer_info = &rx_ring->buffer_info[i];
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   769
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   770
	while (rx_desc->status & E1000_RXD_STAT_DD) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   771
		struct sk_buff *skb;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   772
		u8 status;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   773
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   774
		if (*work_done >= work_to_do)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   775
			break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   776
		(*work_done)++;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   777
		rmb();	/* read descriptor and rx_buffer_info after status DD */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   778
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   779
		status = rx_desc->status;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   780
		skb = buffer_info->skb;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   781
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   782
		if (!adapter->ecdev)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   783
			buffer_info->skb = NULL;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   784
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   785
		prefetch(skb->data - NET_IP_ALIGN);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   786
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   787
		i++;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   788
		if (i == rx_ring->count)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   789
			i = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   790
		next_rxd = E1000_RX_DESC(*rx_ring, i);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   791
		prefetch(next_rxd);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   792
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   793
		next_buffer = &rx_ring->buffer_info[i];
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   794
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   795
		cleaned = 1;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   796
		cleaned_count++;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   797
		dma_unmap_single(&pdev->dev,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   798
				 buffer_info->dma,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   799
				 adapter->rx_buffer_len,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   800
				 DMA_FROM_DEVICE);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   801
		buffer_info->dma = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   802
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   803
		length = le16_to_cpu(rx_desc->length);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   804
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   805
		/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   806
		 * !EOP means multiple descriptors were used to store a single
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   807
		 * packet, if that's the case we need to toss it.  In fact, we
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   808
		 * need to toss every packet with the EOP bit clear and the
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   809
		 * next frame that _does_ have the EOP bit set, as it is by
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   810
		 * definition only a frame fragment
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   811
		 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   812
		if (unlikely(!(status & E1000_RXD_STAT_EOP)))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   813
			adapter->flags2 |= FLAG2_IS_DISCARDING;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   814
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   815
		if (adapter->flags2 & FLAG2_IS_DISCARDING) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   816
			/* All receives must fit into a single buffer */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   817
			e_dbg("Receive packet consumed multiple buffers\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   818
			/* recycle */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   819
			buffer_info->skb = skb;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   820
			if (status & E1000_RXD_STAT_EOP)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   821
				adapter->flags2 &= ~FLAG2_IS_DISCARDING;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   822
			goto next_desc;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   823
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   824
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   825
		if (!adapter->ecdev && (rx_desc->errors & E1000_RXD_ERR_FRAME_ERR_MASK)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   826
			/* recycle */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   827
			buffer_info->skb = skb;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   828
			goto next_desc;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   829
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   830
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   831
		/* adjust length to remove Ethernet CRC */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   832
		if (!(adapter->flags2 & FLAG2_CRC_STRIPPING))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   833
			length -= 4;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   834
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   835
		total_rx_bytes += length;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   836
		total_rx_packets++;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   837
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   838
		/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   839
		 * code added for copybreak, this should improve
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   840
		 * performance for small packets with large amounts
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   841
		 * of reassembly being done in the stack
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   842
		 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   843
		if (!adapter->ecdev && length < copybreak) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   844
			struct sk_buff *new_skb =
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   845
			    netdev_alloc_skb_ip_align(netdev, length);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   846
			if (new_skb) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   847
				skb_copy_to_linear_data_offset(new_skb,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   848
							       -NET_IP_ALIGN,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   849
							       (skb->data -
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   850
								NET_IP_ALIGN),
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   851
							       (length +
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   852
								NET_IP_ALIGN));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   853
				/* save the skb in buffer_info as good */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   854
				buffer_info->skb = skb;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   855
				skb = new_skb;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   856
			}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   857
			/* else just continue with the old one */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   858
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   859
		/* end copybreak code */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   860
		skb_put(skb, length);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   861
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   862
		/* Receive Checksum Offload */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   863
		e1000_rx_checksum(adapter,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   864
				  (u32)(status) |
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   865
				  ((u32)(rx_desc->errors) << 24),
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   866
				  le16_to_cpu(rx_desc->csum), skb);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   867
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   868
		if (adapter->ecdev) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   869
			ecdev_receive(adapter->ecdev, skb->data, length);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   870
			adapter->ec_watchdog_jiffies = jiffies;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   871
		} else {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   872
			e1000_receive_skb(adapter, netdev, skb,status,rx_desc->special);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   873
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   874
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   875
next_desc:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   876
		rx_desc->status = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   877
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   878
		/* return some buffers to hardware, one at a time is too slow */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   879
		if (cleaned_count >= E1000_RX_BUFFER_WRITE) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   880
			adapter->alloc_rx_buf(adapter, cleaned_count);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   881
			cleaned_count = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   882
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   883
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   884
		/* use prefetched values */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   885
		rx_desc = next_rxd;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   886
		buffer_info = next_buffer;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   887
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   888
	rx_ring->next_to_clean = i;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   889
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   890
	cleaned_count = e1000_desc_unused(rx_ring);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   891
	if (cleaned_count)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   892
		adapter->alloc_rx_buf(adapter, cleaned_count);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   893
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   894
	adapter->total_rx_bytes += total_rx_bytes;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   895
	adapter->total_rx_packets += total_rx_packets;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   896
	netdev->stats.rx_bytes += total_rx_bytes;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   897
	netdev->stats.rx_packets += total_rx_packets;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   898
	return cleaned;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   899
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   900
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   901
static void e1000_put_txbuf(struct e1000_adapter *adapter,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   902
			     struct e1000_buffer *buffer_info)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   903
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   904
	if (adapter->ecdev)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   905
		return;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   906
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   907
	if (buffer_info->dma) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   908
		if (buffer_info->mapped_as_page)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   909
			dma_unmap_page(&adapter->pdev->dev, buffer_info->dma,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   910
				       buffer_info->length, DMA_TO_DEVICE);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   911
		else
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   912
			dma_unmap_single(&adapter->pdev->dev, buffer_info->dma,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   913
					 buffer_info->length, DMA_TO_DEVICE);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   914
		buffer_info->dma = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   915
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   916
	if (buffer_info->skb) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   917
		dev_kfree_skb_any(buffer_info->skb);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   918
		buffer_info->skb = NULL;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   919
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   920
	buffer_info->time_stamp = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   921
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   922
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   923
static void e1000_print_hw_hang(struct work_struct *work)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   924
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   925
	struct e1000_adapter *adapter = container_of(work,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   926
	                                             struct e1000_adapter,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   927
	                                             print_hang_task);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   928
	struct e1000_ring *tx_ring = adapter->tx_ring;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   929
	unsigned int i = tx_ring->next_to_clean;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   930
	unsigned int eop = tx_ring->buffer_info[i].next_to_watch;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   931
	struct e1000_tx_desc *eop_desc = E1000_TX_DESC(*tx_ring, eop);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   932
	struct e1000_hw *hw = &adapter->hw;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   933
	u16 phy_status, phy_1000t_status, phy_ext_status;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   934
	u16 pci_status;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   935
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   936
	e1e_rphy(hw, PHY_STATUS, &phy_status);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   937
	e1e_rphy(hw, PHY_1000T_STATUS, &phy_1000t_status);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   938
	e1e_rphy(hw, PHY_EXT_STATUS, &phy_ext_status);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   939
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   940
	pci_read_config_word(adapter->pdev, PCI_STATUS, &pci_status);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   941
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   942
	/* detected Hardware unit hang */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   943
	e_err("Detected Hardware Unit Hang:\n"
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   944
	      "  TDH                  <%x>\n"
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   945
	      "  TDT                  <%x>\n"
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   946
	      "  next_to_use          <%x>\n"
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   947
	      "  next_to_clean        <%x>\n"
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   948
	      "buffer_info[next_to_clean]:\n"
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   949
	      "  time_stamp           <%lx>\n"
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   950
	      "  next_to_watch        <%x>\n"
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   951
	      "  jiffies              <%lx>\n"
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   952
	      "  next_to_watch.status <%x>\n"
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   953
	      "MAC Status             <%x>\n"
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   954
	      "PHY Status             <%x>\n"
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   955
	      "PHY 1000BASE-T Status  <%x>\n"
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   956
	      "PHY Extended Status    <%x>\n"
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   957
	      "PCI Status             <%x>\n",
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   958
	      readl(adapter->hw.hw_addr + tx_ring->head),
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   959
	      readl(adapter->hw.hw_addr + tx_ring->tail),
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   960
	      tx_ring->next_to_use,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   961
	      tx_ring->next_to_clean,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   962
	      tx_ring->buffer_info[eop].time_stamp,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   963
	      eop,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   964
	      jiffies,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   965
	      eop_desc->upper.fields.status,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   966
	      er32(STATUS),
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   967
	      phy_status,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   968
	      phy_1000t_status,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   969
	      phy_ext_status,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   970
	      pci_status);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   971
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   972
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   973
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   974
 * e1000_clean_tx_irq - Reclaim resources after transmit completes
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   975
 * @adapter: board private structure
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   976
 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   977
 * the return value indicates whether actual cleaning was done, there
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   978
 * is no guarantee that everything was cleaned
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   979
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   980
static bool e1000_clean_tx_irq(struct e1000_adapter *adapter)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   981
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   982
	struct net_device *netdev = adapter->netdev;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   983
	struct e1000_hw *hw = &adapter->hw;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   984
	struct e1000_ring *tx_ring = adapter->tx_ring;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   985
	struct e1000_tx_desc *tx_desc, *eop_desc;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   986
	struct e1000_buffer *buffer_info;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   987
	unsigned int i, eop;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   988
	unsigned int count = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   989
	unsigned int total_tx_bytes = 0, total_tx_packets = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   990
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   991
	i = tx_ring->next_to_clean;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   992
	eop = tx_ring->buffer_info[i].next_to_watch;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   993
	eop_desc = E1000_TX_DESC(*tx_ring, eop);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   994
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   995
	while ((eop_desc->upper.data & cpu_to_le32(E1000_TXD_STAT_DD)) &&
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   996
	       (count < tx_ring->count)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   997
		bool cleaned = false;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   998
		rmb(); /* read buffer_info after eop_desc */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   999
		for (; !cleaned; count++) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1000
			tx_desc = E1000_TX_DESC(*tx_ring, i);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1001
			buffer_info = &tx_ring->buffer_info[i];
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1002
			cleaned = (i == eop);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1003
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1004
			if (cleaned) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1005
				total_tx_packets += buffer_info->segs;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1006
				total_tx_bytes += buffer_info->bytecount;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1007
			}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1008
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1009
			e1000_put_txbuf(adapter, buffer_info);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1010
			tx_desc->upper.data = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1011
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1012
			i++;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1013
			if (i == tx_ring->count)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1014
				i = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1015
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1016
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1017
		if (i == tx_ring->next_to_use)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1018
			break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1019
		eop = tx_ring->buffer_info[i].next_to_watch;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1020
		eop_desc = E1000_TX_DESC(*tx_ring, eop);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1021
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1022
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1023
	tx_ring->next_to_clean = i;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1024
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1025
#define TX_WAKE_THRESHOLD 32
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1026
	if (!adapter->ecdev && count && netif_carrier_ok(netdev) &&
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1027
	    e1000_desc_unused(tx_ring) >= TX_WAKE_THRESHOLD) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1028
		/* Make sure that anybody stopping the queue after this
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1029
		 * sees the new next_to_clean.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1030
		 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1031
		smp_mb();
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1032
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1033
		if (netif_queue_stopped(netdev) &&
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1034
		    !(test_bit(__E1000_DOWN, &adapter->state))) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1035
			netif_wake_queue(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1036
			++adapter->restart_queue;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1037
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1038
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1039
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1040
	if (!adapter->ecdev && adapter->detect_tx_hung) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1041
		/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1042
		 * Detect a transmit hang in hardware, this serializes the
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1043
		 * check with the clearing of time_stamp and movement of i
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1044
		 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1045
		adapter->detect_tx_hung = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1046
		if (tx_ring->buffer_info[i].time_stamp &&
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1047
		    time_after(jiffies, tx_ring->buffer_info[i].time_stamp
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1048
			       + (adapter->tx_timeout_factor * HZ)) &&
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1049
		    !(er32(STATUS) & E1000_STATUS_TXOFF)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1050
			schedule_work(&adapter->print_hang_task);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1051
			netif_stop_queue(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1052
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1053
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1054
	adapter->total_tx_bytes += total_tx_bytes;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1055
	adapter->total_tx_packets += total_tx_packets;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1056
	netdev->stats.tx_bytes += total_tx_bytes;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1057
	netdev->stats.tx_packets += total_tx_packets;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1058
	return (count < tx_ring->count);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1059
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1060
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1061
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1062
 * e1000_clean_rx_irq_ps - Send received data up the network stack; packet split
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1063
 * @adapter: board private structure
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1064
 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1065
 * the return value indicates whether actual cleaning was done, there
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1066
 * is no guarantee that everything was cleaned
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1067
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1068
static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1069
				  int *work_done, int work_to_do)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1070
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1071
	struct e1000_hw *hw = &adapter->hw;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1072
	union e1000_rx_desc_packet_split *rx_desc, *next_rxd;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1073
	struct net_device *netdev = adapter->netdev;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1074
	struct pci_dev *pdev = adapter->pdev;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1075
	struct e1000_ring *rx_ring = adapter->rx_ring;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1076
	struct e1000_buffer *buffer_info, *next_buffer;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1077
	struct e1000_ps_page *ps_page;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1078
	struct sk_buff *skb;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1079
	unsigned int i, j;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1080
	u32 length, staterr;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1081
	int cleaned_count = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1082
	bool cleaned = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1083
	unsigned int total_rx_bytes = 0, total_rx_packets = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1084
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1085
	i = rx_ring->next_to_clean;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1086
	rx_desc = E1000_RX_DESC_PS(*rx_ring, i);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1087
	staterr = le32_to_cpu(rx_desc->wb.middle.status_error);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1088
	buffer_info = &rx_ring->buffer_info[i];
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1089
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1090
	while (staterr & E1000_RXD_STAT_DD) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1091
		if (*work_done >= work_to_do)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1092
			break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1093
		(*work_done)++;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1094
		skb = buffer_info->skb;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1095
		rmb();	/* read descriptor and rx_buffer_info after status DD */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1096
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1097
		/* in the packet split case this is header only */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1098
		prefetch(skb->data - NET_IP_ALIGN);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1099
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1100
		i++;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1101
		if (i == rx_ring->count)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1102
			i = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1103
		next_rxd = E1000_RX_DESC_PS(*rx_ring, i);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1104
		prefetch(next_rxd);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1105
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1106
		next_buffer = &rx_ring->buffer_info[i];
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1107
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1108
		cleaned = 1;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1109
		cleaned_count++;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1110
		dma_unmap_single(&pdev->dev, buffer_info->dma,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1111
				 adapter->rx_ps_bsize0,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1112
				 DMA_FROM_DEVICE);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1113
		buffer_info->dma = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1114
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1115
		/* see !EOP comment in other rx routine */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1116
		if (!(staterr & E1000_RXD_STAT_EOP))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1117
			adapter->flags2 |= FLAG2_IS_DISCARDING;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1118
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1119
		if (adapter->flags2 & FLAG2_IS_DISCARDING) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1120
			e_dbg("Packet Split buffers didn't pick up the full "
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1121
			      "packet\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1122
			if (!adapter->ecdev) dev_kfree_skb_irq(skb);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1123
			if (staterr & E1000_RXD_STAT_EOP)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1124
				adapter->flags2 &= ~FLAG2_IS_DISCARDING;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1125
			goto next_desc;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1126
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1127
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1128
		if (staterr & E1000_RXDEXT_ERR_FRAME_ERR_MASK) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1129
			if (!adapter->ecdev)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1130
				dev_kfree_skb_irq(skb);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1131
			goto next_desc;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1132
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1133
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1134
		length = le16_to_cpu(rx_desc->wb.middle.length0);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1135
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1136
		if (!length) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1137
			e_dbg("Last part of the packet spanning multiple "
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1138
			      "descriptors\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1139
			if (!adapter->ecdev)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1140
				dev_kfree_skb_irq(skb);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1141
			goto next_desc;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1142
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1143
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1144
		/* Good Receive */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1145
		skb_put(skb, length);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1146
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1147
		{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1148
		/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1149
		 * this looks ugly, but it seems compiler issues make it
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1150
		 * more efficient than reusing j
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1151
		 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1152
		int l1 = le16_to_cpu(rx_desc->wb.upper.length[0]);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1153
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1154
		/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1155
		 * page alloc/put takes too long and effects small packet
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1156
		 * throughput, so unsplit small packets and save the alloc/put
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1157
		 * only valid in softirq (napi) context to call kmap_*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1158
		 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1159
		if (l1 && (l1 <= copybreak) &&
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1160
		    ((length + l1) <= adapter->rx_ps_bsize0)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1161
			u8 *vaddr;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1162
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1163
			ps_page = &buffer_info->ps_pages[0];
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1164
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1165
			/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1166
			 * there is no documentation about how to call
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1167
			 * kmap_atomic, so we can't hold the mapping
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1168
			 * very long
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1169
			 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1170
			dma_sync_single_for_cpu(&pdev->dev, ps_page->dma,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1171
						PAGE_SIZE, DMA_FROM_DEVICE);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1172
			vaddr = kmap_atomic(ps_page->page, KM_SKB_DATA_SOFTIRQ);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1173
			memcpy(skb_tail_pointer(skb), vaddr, l1);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1174
			kunmap_atomic(vaddr, KM_SKB_DATA_SOFTIRQ);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1175
			dma_sync_single_for_device(&pdev->dev, ps_page->dma,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1176
						   PAGE_SIZE, DMA_FROM_DEVICE);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1177
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1178
			/* remove the CRC */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1179
			if (!(adapter->flags2 & FLAG2_CRC_STRIPPING))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1180
				l1 -= 4;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1181
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1182
			skb_put(skb, l1);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1183
			goto copydone;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1184
		} /* if */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1185
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1186
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1187
		for (j = 0; j < PS_PAGE_BUFFERS; j++) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1188
			length = le16_to_cpu(rx_desc->wb.upper.length[j]);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1189
			if (!length)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1190
				break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1191
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1192
			ps_page = &buffer_info->ps_pages[j];
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1193
			dma_unmap_page(&pdev->dev, ps_page->dma, PAGE_SIZE,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1194
				       DMA_FROM_DEVICE);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1195
			ps_page->dma = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1196
			skb_fill_page_desc(skb, j, ps_page->page, 0, length);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1197
			ps_page->page = NULL;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1198
			skb->len += length;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1199
			skb->data_len += length;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1200
			skb->truesize += length;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1201
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1202
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1203
		/* strip the ethernet crc, problem is we're using pages now so
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1204
		 * this whole operation can get a little cpu intensive
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1205
		 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1206
		if (!(adapter->flags2 & FLAG2_CRC_STRIPPING))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1207
			pskb_trim(skb, skb->len - 4);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1208
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1209
copydone:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1210
		total_rx_bytes += skb->len;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1211
		total_rx_packets++;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1212
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1213
		e1000_rx_checksum(adapter, staterr, le16_to_cpu(
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1214
			rx_desc->wb.lower.hi_dword.csum_ip.csum), skb);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1215
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1216
		if (rx_desc->wb.upper.header_status &
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1217
			   cpu_to_le16(E1000_RXDPS_HDRSTAT_HDRSP))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1218
			adapter->rx_hdr_split++;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1219
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1220
		if (adapter->ecdev) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1221
			ecdev_receive(adapter->ecdev, skb->data, length);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1222
			adapter->ec_watchdog_jiffies = jiffies;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1223
		} else {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1224
			e1000_receive_skb(adapter, netdev, skb,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1225
					  staterr, rx_desc->wb.middle.vlan);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1226
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1227
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1228
next_desc:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1229
		rx_desc->wb.middle.status_error &= cpu_to_le32(~0xFF);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1230
		if (!adapter->ecdev) buffer_info->skb = NULL;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1231
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1232
		/* return some buffers to hardware, one at a time is too slow */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1233
		if (cleaned_count >= E1000_RX_BUFFER_WRITE) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1234
			adapter->alloc_rx_buf(adapter, cleaned_count);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1235
			cleaned_count = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1236
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1237
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1238
		/* use prefetched values */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1239
		rx_desc = next_rxd;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1240
		buffer_info = next_buffer;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1241
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1242
		staterr = le32_to_cpu(rx_desc->wb.middle.status_error);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1243
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1244
	rx_ring->next_to_clean = i;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1245
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1246
	cleaned_count = e1000_desc_unused(rx_ring);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1247
	if (cleaned_count)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1248
		adapter->alloc_rx_buf(adapter, cleaned_count);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1249
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1250
	adapter->total_rx_bytes += total_rx_bytes;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1251
	adapter->total_rx_packets += total_rx_packets;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1252
	netdev->stats.rx_bytes += total_rx_bytes;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1253
	netdev->stats.rx_packets += total_rx_packets;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1254
	return cleaned;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1255
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1256
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1257
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1258
 * e1000_consume_page - helper function
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1259
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1260
static void e1000_consume_page(struct e1000_buffer *bi, struct sk_buff *skb,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1261
                               u16 length)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1262
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1263
	bi->page = NULL;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1264
	skb->len += length;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1265
	skb->data_len += length;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1266
	skb->truesize += length;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1267
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1268
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1269
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1270
 * e1000_clean_jumbo_rx_irq - Send received data up the network stack; legacy
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1271
 * @adapter: board private structure
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1272
 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1273
 * the return value indicates whether actual cleaning was done, there
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1274
 * is no guarantee that everything was cleaned
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1275
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1276
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1277
static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1278
                                     int *work_done, int work_to_do)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1279
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1280
	struct net_device *netdev = adapter->netdev;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1281
	struct pci_dev *pdev = adapter->pdev;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1282
	struct e1000_ring *rx_ring = adapter->rx_ring;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1283
	struct e1000_rx_desc *rx_desc, *next_rxd;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1284
	struct e1000_buffer *buffer_info, *next_buffer;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1285
	u32 length;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1286
	unsigned int i;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1287
	int cleaned_count = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1288
	bool cleaned = false;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1289
	unsigned int total_rx_bytes=0, total_rx_packets=0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1290
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1291
	i = rx_ring->next_to_clean;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1292
	rx_desc = E1000_RX_DESC(*rx_ring, i);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1293
	buffer_info = &rx_ring->buffer_info[i];
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1294
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1295
	while (rx_desc->status & E1000_RXD_STAT_DD) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1296
		struct sk_buff *skb;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1297
		u8 status;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1298
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1299
		if (*work_done >= work_to_do)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1300
			break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1301
		(*work_done)++;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1302
		rmb();	/* read descriptor and rx_buffer_info after status DD */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1303
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1304
		status = rx_desc->status;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1305
		skb = buffer_info->skb;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1306
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1307
		if (!adapter->ecdev)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1308
			buffer_info->skb = NULL;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1309
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1310
		++i;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1311
		if (i == rx_ring->count)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1312
			i = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1313
		next_rxd = E1000_RX_DESC(*rx_ring, i);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1314
		prefetch(next_rxd);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1315
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1316
		next_buffer = &rx_ring->buffer_info[i];
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1317
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1318
		cleaned = true;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1319
		cleaned_count++;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1320
		dma_unmap_page(&pdev->dev, buffer_info->dma, PAGE_SIZE,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1321
			       DMA_FROM_DEVICE);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1322
		buffer_info->dma = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1323
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1324
		length = le16_to_cpu(rx_desc->length);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1325
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1326
		/* errors is only valid for DD + EOP descriptors */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1327
		if (!adapter->ecdev && unlikely((status & E1000_RXD_STAT_EOP) &&
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1328
		    (rx_desc->errors & E1000_RXD_ERR_FRAME_ERR_MASK))) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1329
				/* recycle both page and skb */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1330
				buffer_info->skb = skb;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1331
				/* an error means any chain goes out the window
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1332
				 * too */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1333
				if (rx_ring->rx_skb_top)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1334
					dev_kfree_skb(rx_ring->rx_skb_top);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1335
				rx_ring->rx_skb_top = NULL;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1336
				goto next_desc;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1337
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1338
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1339
#define rxtop rx_ring->rx_skb_top
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1340
		if (!(status & E1000_RXD_STAT_EOP)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1341
			/* this descriptor is only the beginning (or middle) */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1342
			if (!rxtop) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1343
				/* this is the beginning of a chain */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1344
				rxtop = skb;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1345
				skb_fill_page_desc(rxtop, 0, buffer_info->page,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1346
				                   0, length);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1347
			} else {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1348
				/* this is the middle of a chain */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1349
				skb_fill_page_desc(rxtop,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1350
				    skb_shinfo(rxtop)->nr_frags,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1351
				    buffer_info->page, 0, length);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1352
				/* re-use the skb, only consumed the page */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1353
				buffer_info->skb = skb;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1354
			}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1355
			e1000_consume_page(buffer_info, rxtop, length);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1356
			goto next_desc;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1357
		} else {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1358
			if (rxtop) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1359
				/* end of the chain */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1360
				skb_fill_page_desc(rxtop,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1361
				    skb_shinfo(rxtop)->nr_frags,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1362
				    buffer_info->page, 0, length);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1363
				/* re-use the current skb, we only consumed the
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1364
				 * page */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1365
				buffer_info->skb = skb;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1366
				skb = rxtop;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1367
				rxtop = NULL;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1368
				e1000_consume_page(buffer_info, skb, length);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1369
			} else {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1370
				/* no chain, got EOP, this buf is the packet
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1371
				 * copybreak to save the put_page/alloc_page */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1372
				if (length <= copybreak &&
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1373
				    skb_tailroom(skb) >= length) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1374
					u8 *vaddr;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1375
					vaddr = kmap_atomic(buffer_info->page,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1376
					                   KM_SKB_DATA_SOFTIRQ);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1377
					memcpy(skb_tail_pointer(skb), vaddr,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1378
					       length);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1379
					kunmap_atomic(vaddr,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1380
					              KM_SKB_DATA_SOFTIRQ);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1381
					/* re-use the page, so don't erase
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1382
					 * buffer_info->page */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1383
					skb_put(skb, length);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1384
				} else {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1385
					skb_fill_page_desc(skb, 0,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1386
					                   buffer_info->page, 0,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1387
				                           length);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1388
					e1000_consume_page(buffer_info, skb,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1389
					                   length);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1390
				}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1391
			}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1392
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1393
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1394
		/* Receive Checksum Offload XXX recompute due to CRC strip? */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1395
		e1000_rx_checksum(adapter,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1396
		                  (u32)(status) |
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1397
		                  ((u32)(rx_desc->errors) << 24),
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1398
		                  le16_to_cpu(rx_desc->csum), skb);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1399
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1400
		/* probably a little skewed due to removing CRC */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1401
		total_rx_bytes += skb->len;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1402
		total_rx_packets++;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1403
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1404
		/* eth type trans needs skb->data to point to something */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1405
		if (!adapter->ecdev && !pskb_may_pull(skb, ETH_HLEN)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1406
			e_err("pskb_may_pull failed.\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1407
			dev_kfree_skb(skb);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1408
			goto next_desc;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1409
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1410
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1411
		if (adapter->ecdev) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1412
			ecdev_receive(adapter->ecdev, skb->data, length);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1413
			adapter->ec_watchdog_jiffies = jiffies;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1414
		} else {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1415
			e1000_receive_skb(adapter, netdev, skb, status,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1416
			                  rx_desc->special);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1417
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1418
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1419
next_desc:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1420
		rx_desc->status = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1421
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1422
		/* return some buffers to hardware, one at a time is too slow */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1423
		if (unlikely(cleaned_count >= E1000_RX_BUFFER_WRITE)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1424
			adapter->alloc_rx_buf(adapter, cleaned_count);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1425
			cleaned_count = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1426
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1427
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1428
		/* use prefetched values */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1429
		rx_desc = next_rxd;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1430
		buffer_info = next_buffer;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1431
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1432
	rx_ring->next_to_clean = i;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1433
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1434
	cleaned_count = e1000_desc_unused(rx_ring);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1435
	if (cleaned_count)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1436
		adapter->alloc_rx_buf(adapter, cleaned_count);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1437
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1438
	adapter->total_rx_bytes += total_rx_bytes;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1439
	adapter->total_rx_packets += total_rx_packets;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1440
	netdev->stats.rx_bytes += total_rx_bytes;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1441
	netdev->stats.rx_packets += total_rx_packets;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1442
	return cleaned;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1443
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1444
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1445
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1446
 * e1000_clean_rx_ring - Free Rx Buffers per Queue
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1447
 * @adapter: board private structure
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1448
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1449
static void e1000_clean_rx_ring(struct e1000_adapter *adapter)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1450
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1451
	struct e1000_ring *rx_ring = adapter->rx_ring;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1452
	struct e1000_buffer *buffer_info;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1453
	struct e1000_ps_page *ps_page;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1454
	struct pci_dev *pdev = adapter->pdev;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1455
	unsigned int i, j;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1456
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1457
	/* Free all the Rx ring sk_buffs */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1458
	for (i = 0; i < rx_ring->count; i++) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1459
		buffer_info = &rx_ring->buffer_info[i];
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1460
		if (buffer_info->dma) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1461
			if (adapter->clean_rx == e1000_clean_rx_irq)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1462
				dma_unmap_single(&pdev->dev, buffer_info->dma,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1463
						 adapter->rx_buffer_len,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1464
						 DMA_FROM_DEVICE);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1465
			else if (adapter->clean_rx == e1000_clean_jumbo_rx_irq)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1466
				dma_unmap_page(&pdev->dev, buffer_info->dma,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1467
				               PAGE_SIZE,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1468
					       DMA_FROM_DEVICE);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1469
			else if (adapter->clean_rx == e1000_clean_rx_irq_ps)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1470
				dma_unmap_single(&pdev->dev, buffer_info->dma,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1471
						 adapter->rx_ps_bsize0,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1472
						 DMA_FROM_DEVICE);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1473
			buffer_info->dma = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1474
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1475
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1476
		if (buffer_info->page) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1477
			put_page(buffer_info->page);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1478
			buffer_info->page = NULL;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1479
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1480
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1481
		if (buffer_info->skb) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1482
			dev_kfree_skb(buffer_info->skb);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1483
			buffer_info->skb = NULL;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1484
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1485
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1486
		for (j = 0; j < PS_PAGE_BUFFERS; j++) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1487
			ps_page = &buffer_info->ps_pages[j];
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1488
			if (!ps_page->page)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1489
				break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1490
			dma_unmap_page(&pdev->dev, ps_page->dma, PAGE_SIZE,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1491
				       DMA_FROM_DEVICE);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1492
			ps_page->dma = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1493
			put_page(ps_page->page);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1494
			ps_page->page = NULL;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1495
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1496
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1497
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1498
	/* there also may be some cached data from a chained receive */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1499
	if (rx_ring->rx_skb_top) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1500
		dev_kfree_skb(rx_ring->rx_skb_top);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1501
		rx_ring->rx_skb_top = NULL;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1502
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1503
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1504
	/* Zero out the descriptor ring */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1505
	memset(rx_ring->desc, 0, rx_ring->size);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1506
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1507
	rx_ring->next_to_clean = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1508
	rx_ring->next_to_use = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1509
	adapter->flags2 &= ~FLAG2_IS_DISCARDING;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1510
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1511
	writel(0, adapter->hw.hw_addr + rx_ring->head);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1512
	writel(0, adapter->hw.hw_addr + rx_ring->tail);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1513
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1514
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1515
static void e1000e_downshift_workaround(struct work_struct *work)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1516
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1517
	struct e1000_adapter *adapter = container_of(work,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1518
					struct e1000_adapter, downshift_task);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1519
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1520
	e1000e_gig_downshift_workaround_ich8lan(&adapter->hw);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1521
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1522
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1523
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1524
 * e1000_intr_msi - Interrupt Handler
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1525
 * @irq: interrupt number
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1526
 * @data: pointer to a network interface device structure
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1527
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1528
static irqreturn_t e1000_intr_msi(int irq, void *data)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1529
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1530
	struct net_device *netdev = data;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1531
	struct e1000_adapter *adapter = netdev_priv(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1532
	struct e1000_hw *hw = &adapter->hw;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1533
	u32 icr = er32(ICR);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1534
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1535
 	if (adapter->ecdev) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1536
 		int ec_work_done = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1537
 		adapter->clean_rx(adapter, &ec_work_done, 100);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1538
 		e1000_clean_tx_irq(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1539
		return IRQ_HANDLED;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1540
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1541
	/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1542
	 * read ICR disables interrupts using IAM
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1543
	 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1544
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1545
	if (icr & E1000_ICR_LSC) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1546
		hw->mac.get_link_status = 1;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1547
		/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1548
		 * ICH8 workaround-- Call gig speed drop workaround on cable
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1549
		 * disconnect (LSC) before accessing any PHY registers
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1550
		 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1551
		if ((adapter->flags & FLAG_LSC_GIG_SPEED_DROP) &&
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1552
		    (!(er32(STATUS) & E1000_STATUS_LU)))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1553
			schedule_work(&adapter->downshift_task);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1554
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1555
		/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1556
		 * 80003ES2LAN workaround-- For packet buffer work-around on
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1557
		 * link down event; disable receives here in the ISR and reset
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1558
		 * adapter in watchdog
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1559
		 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1560
		if (netif_carrier_ok(netdev) &&
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1561
		    adapter->flags & FLAG_RX_NEEDS_RESTART) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1562
			/* disable receives */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1563
			u32 rctl = er32(RCTL);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1564
			ew32(RCTL, rctl & ~E1000_RCTL_EN);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1565
			adapter->flags |= FLAG_RX_RESTART_NOW;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1566
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1567
		/* guard against interrupt when we're going down */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1568
		if (!test_bit(__E1000_DOWN, &adapter->state))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1569
			mod_timer(&adapter->watchdog_timer, jiffies + 1);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1570
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1571
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1572
	if (napi_schedule_prep(&adapter->napi)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1573
		adapter->total_tx_bytes = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1574
		adapter->total_tx_packets = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1575
		adapter->total_rx_bytes = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1576
		adapter->total_rx_packets = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1577
		__napi_schedule(&adapter->napi);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1578
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1579
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1580
	return IRQ_HANDLED;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1581
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1582
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1583
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1584
 * e1000_intr - Interrupt Handler
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1585
 * @irq: interrupt number
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1586
 * @data: pointer to a network interface device structure
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1587
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1588
static irqreturn_t e1000_intr(int irq, void *data)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1589
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1590
	struct net_device *netdev = data;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1591
	struct e1000_adapter *adapter = netdev_priv(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1592
	struct e1000_hw *hw = &adapter->hw;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1593
	u32 rctl, icr = er32(ICR);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1594
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1595
	if (!icr || test_bit(__E1000_DOWN, &adapter->state))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1596
		return IRQ_NONE;  /* Not our interrupt */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1597
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1598
	/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1599
	 * IMS will not auto-mask if INT_ASSERTED is not set, and if it is
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1600
	 * not set, then the adapter didn't send an interrupt
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1601
	 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1602
	if (!adapter->ecdev && !(icr & E1000_ICR_INT_ASSERTED))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1603
		return IRQ_NONE;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1604
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1605
	/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1606
	 * Interrupt Auto-Mask...upon reading ICR,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1607
	 * interrupts are masked.  No need for the
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1608
	 * IMC write
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1609
	 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1610
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1611
	if (!adapter->ecdev && (icr & E1000_ICR_LSC)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1612
		hw->mac.get_link_status = 1;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1613
		/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1614
		 * ICH8 workaround-- Call gig speed drop workaround on cable
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1615
		 * disconnect (LSC) before accessing any PHY registers
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1616
		 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1617
		if ((adapter->flags & FLAG_LSC_GIG_SPEED_DROP) &&
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1618
		    (!(er32(STATUS) & E1000_STATUS_LU)))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1619
			schedule_work(&adapter->downshift_task);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1620
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1621
		/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1622
		 * 80003ES2LAN workaround--
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1623
		 * For packet buffer work-around on link down event;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1624
		 * disable receives here in the ISR and
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1625
		 * reset adapter in watchdog
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1626
		 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1627
		if (netif_carrier_ok(netdev) &&
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1628
		    (adapter->flags & FLAG_RX_NEEDS_RESTART)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1629
			/* disable receives */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1630
			rctl = er32(RCTL);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1631
			ew32(RCTL, rctl & ~E1000_RCTL_EN);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1632
			adapter->flags |= FLAG_RX_RESTART_NOW;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1633
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1634
		/* guard against interrupt when we're going down */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1635
		if (!test_bit(__E1000_DOWN, &adapter->state))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1636
			mod_timer(&adapter->watchdog_timer, jiffies + 1);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1637
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1638
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1639
 	if (adapter->ecdev) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1640
 		int ec_work_done = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1641
 		adapter->clean_rx(adapter, &ec_work_done, 100);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1642
 		e1000_clean_tx_irq(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1643
		return IRQ_HANDLED;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1644
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1645
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1646
	if (napi_schedule_prep(&adapter->napi)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1647
		adapter->total_tx_bytes = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1648
		adapter->total_tx_packets = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1649
		adapter->total_rx_bytes = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1650
		adapter->total_rx_packets = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1651
		__napi_schedule(&adapter->napi);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1652
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1653
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1654
	return IRQ_HANDLED;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1655
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1656
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1657
static irqreturn_t e1000_msix_other(int irq, void *data)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1658
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1659
	struct net_device *netdev = data;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1660
	struct e1000_adapter *adapter = netdev_priv(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1661
	struct e1000_hw *hw = &adapter->hw;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1662
	u32 icr = er32(ICR);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1663
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1664
	if (!(icr & E1000_ICR_INT_ASSERTED)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1665
		if (!test_bit(__E1000_DOWN, &adapter->state))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1666
			ew32(IMS, E1000_IMS_OTHER);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1667
		return IRQ_NONE;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1668
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1669
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1670
	if (icr & adapter->eiac_mask)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1671
		ew32(ICS, (icr & adapter->eiac_mask));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1672
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1673
	if (icr & E1000_ICR_OTHER) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1674
		if (!(icr & E1000_ICR_LSC))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1675
			goto no_link_interrupt;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1676
		hw->mac.get_link_status = 1;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1677
		/* guard against interrupt when we're going down */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1678
		if (!adapter->ecdev && !test_bit(__E1000_DOWN, &adapter->state))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1679
			mod_timer(&adapter->watchdog_timer, jiffies + 1);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1680
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1681
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1682
no_link_interrupt:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1683
	if (!test_bit(__E1000_DOWN, &adapter->state))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1684
		ew32(IMS, E1000_IMS_LSC | E1000_IMS_OTHER);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1685
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1686
	return IRQ_HANDLED;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1687
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1688
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1689
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1690
static irqreturn_t e1000_intr_msix_tx(int irq, void *data)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1691
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1692
	struct net_device *netdev = data;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1693
	struct e1000_adapter *adapter = netdev_priv(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1694
	struct e1000_hw *hw = &adapter->hw;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1695
	struct e1000_ring *tx_ring = adapter->tx_ring;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1696
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1697
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1698
	adapter->total_tx_bytes = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1699
	adapter->total_tx_packets = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1700
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1701
	if (!e1000_clean_tx_irq(adapter))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1702
		/* Ring was not completely cleaned, so fire another interrupt */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1703
		ew32(ICS, tx_ring->ims_val);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1704
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1705
	return IRQ_HANDLED;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1706
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1707
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1708
static irqreturn_t e1000_intr_msix_rx(int irq, void *data)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1709
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1710
	struct net_device *netdev = data;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1711
	struct e1000_adapter *adapter = netdev_priv(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1712
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1713
	/* Write the ITR value calculated at the end of the
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1714
	 * previous interrupt.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1715
	 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1716
	if (adapter->rx_ring->set_itr) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1717
		writel(1000000000 / (adapter->rx_ring->itr_val * 256),
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1718
		       adapter->hw.hw_addr + adapter->rx_ring->itr_register);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1719
		adapter->rx_ring->set_itr = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1720
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1721
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1722
 	if (adapter->ecdev) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1723
 		int ec_work_done = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1724
 		adapter->clean_rx(adapter, &ec_work_done, 100);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1725
	} else {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1726
		if (napi_schedule_prep(&adapter->napi)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1727
			adapter->total_rx_bytes = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1728
			adapter->total_rx_packets = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1729
			__napi_schedule(&adapter->napi);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1730
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1731
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1732
	return IRQ_HANDLED;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1733
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1734
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1735
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1736
 * e1000_configure_msix - Configure MSI-X hardware
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1737
 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1738
 * e1000_configure_msix sets up the hardware to properly
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1739
 * generate MSI-X interrupts.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1740
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1741
static void e1000_configure_msix(struct e1000_adapter *adapter)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1742
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1743
	struct e1000_hw *hw = &adapter->hw;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1744
	struct e1000_ring *rx_ring = adapter->rx_ring;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1745
	struct e1000_ring *tx_ring = adapter->tx_ring;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1746
	int vector = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1747
	u32 ctrl_ext, ivar = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1748
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1749
	adapter->eiac_mask = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1750
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1751
	/* Workaround issue with spurious interrupts on 82574 in MSI-X mode */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1752
	if (hw->mac.type == e1000_82574) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1753
		u32 rfctl = er32(RFCTL);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1754
		rfctl |= E1000_RFCTL_ACK_DIS;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1755
		ew32(RFCTL, rfctl);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1756
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1757
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1758
#define E1000_IVAR_INT_ALLOC_VALID	0x8
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1759
	/* Configure Rx vector */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1760
	rx_ring->ims_val = E1000_IMS_RXQ0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1761
	adapter->eiac_mask |= rx_ring->ims_val;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1762
	if (rx_ring->itr_val)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1763
		writel(1000000000 / (rx_ring->itr_val * 256),
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1764
		       hw->hw_addr + rx_ring->itr_register);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1765
	else
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1766
		writel(1, hw->hw_addr + rx_ring->itr_register);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1767
	ivar = E1000_IVAR_INT_ALLOC_VALID | vector;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1768
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1769
	/* Configure Tx vector */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1770
	tx_ring->ims_val = E1000_IMS_TXQ0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1771
	vector++;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1772
	if (tx_ring->itr_val)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1773
		writel(1000000000 / (tx_ring->itr_val * 256),
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1774
		       hw->hw_addr + tx_ring->itr_register);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1775
	else
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1776
		writel(1, hw->hw_addr + tx_ring->itr_register);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1777
	adapter->eiac_mask |= tx_ring->ims_val;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1778
	ivar |= ((E1000_IVAR_INT_ALLOC_VALID | vector) << 8);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1779
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1780
	/* set vector for Other Causes, e.g. link changes */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1781
	vector++;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1782
	ivar |= ((E1000_IVAR_INT_ALLOC_VALID | vector) << 16);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1783
	if (rx_ring->itr_val)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1784
		writel(1000000000 / (rx_ring->itr_val * 256),
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1785
		       hw->hw_addr + E1000_EITR_82574(vector));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1786
	else
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1787
		writel(1, hw->hw_addr + E1000_EITR_82574(vector));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1788
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1789
	/* Cause Tx interrupts on every write back */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1790
	ivar |= (1 << 31);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1791
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1792
	ew32(IVAR, ivar);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1793
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1794
	/* enable MSI-X PBA support */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1795
	ctrl_ext = er32(CTRL_EXT);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1796
	ctrl_ext |= E1000_CTRL_EXT_PBA_CLR;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1797
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1798
	/* Auto-Mask Other interrupts upon ICR read */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1799
#define E1000_EIAC_MASK_82574   0x01F00000
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1800
	ew32(IAM, ~E1000_EIAC_MASK_82574 | E1000_IMS_OTHER);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1801
	ctrl_ext |= E1000_CTRL_EXT_EIAME;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1802
	ew32(CTRL_EXT, ctrl_ext);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1803
	e1e_flush();
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1804
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1805
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1806
void e1000e_reset_interrupt_capability(struct e1000_adapter *adapter)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1807
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1808
	if (adapter->msix_entries) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1809
		pci_disable_msix(adapter->pdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1810
		kfree(adapter->msix_entries);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1811
		adapter->msix_entries = NULL;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1812
	} else if (adapter->flags & FLAG_MSI_ENABLED) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1813
		pci_disable_msi(adapter->pdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1814
		adapter->flags &= ~FLAG_MSI_ENABLED;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1815
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1816
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1817
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1818
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1819
 * e1000e_set_interrupt_capability - set MSI or MSI-X if supported
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1820
 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1821
 * Attempt to configure interrupts using the best available
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1822
 * capabilities of the hardware and kernel.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1823
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1824
void e1000e_set_interrupt_capability(struct e1000_adapter *adapter)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1825
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1826
	int err;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1827
	int numvecs, i;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1828
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1829
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1830
	switch (adapter->int_mode) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1831
	case E1000E_INT_MODE_MSIX:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1832
		if (adapter->flags & FLAG_HAS_MSIX) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1833
			numvecs = 3; /* RxQ0, TxQ0 and other */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1834
			adapter->msix_entries = kcalloc(numvecs,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1835
						      sizeof(struct msix_entry),
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1836
						      GFP_KERNEL);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1837
			if (adapter->msix_entries) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1838
				for (i = 0; i < numvecs; i++)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1839
					adapter->msix_entries[i].entry = i;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1840
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1841
				err = pci_enable_msix(adapter->pdev,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1842
						      adapter->msix_entries,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1843
						      numvecs);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1844
				if (err == 0)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1845
					return;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1846
			}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1847
			/* MSI-X failed, so fall through and try MSI */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1848
			e_err("Failed to initialize MSI-X interrupts.  "
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1849
			      "Falling back to MSI interrupts.\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1850
			e1000e_reset_interrupt_capability(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1851
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1852
		adapter->int_mode = E1000E_INT_MODE_MSI;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1853
		/* Fall through */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1854
	case E1000E_INT_MODE_MSI:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1855
		if (!pci_enable_msi(adapter->pdev)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1856
			adapter->flags |= FLAG_MSI_ENABLED;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1857
		} else {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1858
			adapter->int_mode = E1000E_INT_MODE_LEGACY;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1859
			e_err("Failed to initialize MSI interrupts.  Falling "
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1860
			      "back to legacy interrupts.\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1861
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1862
		/* Fall through */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1863
	case E1000E_INT_MODE_LEGACY:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1864
		/* Don't do anything; this is the system default */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1865
		break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1866
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1867
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1868
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1869
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1870
 * e1000_request_msix - Initialize MSI-X interrupts
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1871
 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1872
 * e1000_request_msix allocates MSI-X vectors and requests interrupts from the
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1873
 * kernel.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1874
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1875
static int e1000_request_msix(struct e1000_adapter *adapter)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1876
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1877
	struct net_device *netdev = adapter->netdev;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1878
	int err = 0, vector = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1879
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1880
	if (strlen(netdev->name) < (IFNAMSIZ - 5))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1881
		sprintf(adapter->rx_ring->name, "%s-rx-0", netdev->name);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1882
	else
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1883
		memcpy(adapter->rx_ring->name, netdev->name, IFNAMSIZ);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1884
	err = request_irq(adapter->msix_entries[vector].vector,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1885
			  e1000_intr_msix_rx, 0, adapter->rx_ring->name,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1886
			  netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1887
	if (err)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1888
		goto out;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1889
	adapter->rx_ring->itr_register = E1000_EITR_82574(vector);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1890
	adapter->rx_ring->itr_val = adapter->itr;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1891
	vector++;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1892
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1893
	if (strlen(netdev->name) < (IFNAMSIZ - 5))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1894
		sprintf(adapter->tx_ring->name, "%s-tx-0", netdev->name);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1895
	else
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1896
		memcpy(adapter->tx_ring->name, netdev->name, IFNAMSIZ);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1897
	err = request_irq(adapter->msix_entries[vector].vector,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1898
			  e1000_intr_msix_tx, 0, adapter->tx_ring->name,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1899
			  netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1900
	if (err)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1901
		goto out;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1902
	adapter->tx_ring->itr_register = E1000_EITR_82574(vector);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1903
	adapter->tx_ring->itr_val = adapter->itr;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1904
	vector++;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1905
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1906
	err = request_irq(adapter->msix_entries[vector].vector,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1907
			  e1000_msix_other, 0, netdev->name, netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1908
	if (err)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1909
		goto out;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1910
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1911
	e1000_configure_msix(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1912
	return 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1913
out:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1914
	return err;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1915
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1916
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1917
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1918
 * e1000_request_irq - initialize interrupts
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1919
 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1920
 * Attempts to configure interrupts using the best available
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1921
 * capabilities of the hardware and kernel.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1922
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1923
static int e1000_request_irq(struct e1000_adapter *adapter)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1924
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1925
	struct net_device *netdev = adapter->netdev;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1926
	int err;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1927
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1928
	if (adapter->ecdev)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1929
		return 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1930
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1931
	if (adapter->msix_entries) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1932
		err = e1000_request_msix(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1933
		if (!err)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1934
			return err;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1935
		/* fall back to MSI */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1936
		e1000e_reset_interrupt_capability(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1937
		adapter->int_mode = E1000E_INT_MODE_MSI;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1938
		e1000e_set_interrupt_capability(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1939
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1940
	if (adapter->flags & FLAG_MSI_ENABLED) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1941
		err = request_irq(adapter->pdev->irq, e1000_intr_msi, 0,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1942
				  netdev->name, netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1943
		if (!err)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1944
			return err;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1945
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1946
		/* fall back to legacy interrupt */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1947
		e1000e_reset_interrupt_capability(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1948
		adapter->int_mode = E1000E_INT_MODE_LEGACY;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1949
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1950
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1951
	err = request_irq(adapter->pdev->irq, e1000_intr, IRQF_SHARED,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1952
			  netdev->name, netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1953
	if (err)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1954
		e_err("Unable to allocate interrupt, Error: %d\n", err);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1955
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1956
	return err;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1957
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1958
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1959
static void e1000_free_irq(struct e1000_adapter *adapter)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1960
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1961
	struct net_device *netdev = adapter->netdev;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1962
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1963
	if (adapter->ecdev)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1964
		return;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1965
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1966
	if (adapter->msix_entries) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1967
		int vector = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1968
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1969
		free_irq(adapter->msix_entries[vector].vector, netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1970
		vector++;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1971
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1972
		free_irq(adapter->msix_entries[vector].vector, netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1973
		vector++;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1974
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1975
		/* Other Causes interrupt vector */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1976
		free_irq(adapter->msix_entries[vector].vector, netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1977
		return;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1978
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1979
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1980
	free_irq(adapter->pdev->irq, netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1981
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1982
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1983
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1984
 * e1000_irq_disable - Mask off interrupt generation on the NIC
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1985
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1986
static void e1000_irq_disable(struct e1000_adapter *adapter)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1987
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1988
	struct e1000_hw *hw = &adapter->hw;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1989
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1990
	if (adapter->ecdev)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1991
		return;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1992
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1993
	ew32(IMC, ~0);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1994
	if (adapter->msix_entries)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1995
		ew32(EIAC_82574, 0);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1996
	e1e_flush();
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1997
	synchronize_irq(adapter->pdev->irq);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1998
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1999
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2000
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2001
 * e1000_irq_enable - Enable default interrupt generation settings
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2002
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2003
static void e1000_irq_enable(struct e1000_adapter *adapter)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2004
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2005
	struct e1000_hw *hw = &adapter->hw;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2006
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2007
	if (adapter->ecdev)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2008
		return;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2009
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2010
	if (adapter->msix_entries) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2011
		ew32(EIAC_82574, adapter->eiac_mask & E1000_EIAC_MASK_82574);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2012
		ew32(IMS, adapter->eiac_mask | E1000_IMS_OTHER | E1000_IMS_LSC);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2013
	} else {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2014
		ew32(IMS, IMS_ENABLE_MASK);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2015
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2016
	e1e_flush();
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2017
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2018
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2019
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2020
 * e1000_get_hw_control - get control of the h/w from f/w
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2021
 * @adapter: address of board private structure
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2022
 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2023
 * e1000_get_hw_control sets {CTRL_EXT|SWSM}:DRV_LOAD bit.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2024
 * For ASF and Pass Through versions of f/w this means that
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2025
 * the driver is loaded. For AMT version (only with 82573)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2026
 * of the f/w this means that the network i/f is open.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2027
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2028
static void e1000_get_hw_control(struct e1000_adapter *adapter)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2029
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2030
	struct e1000_hw *hw = &adapter->hw;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2031
	u32 ctrl_ext;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2032
	u32 swsm;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2033
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2034
	/* Let firmware know the driver has taken over */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2035
	if (adapter->flags & FLAG_HAS_SWSM_ON_LOAD) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2036
		swsm = er32(SWSM);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2037
		ew32(SWSM, swsm | E1000_SWSM_DRV_LOAD);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2038
	} else if (adapter->flags & FLAG_HAS_CTRLEXT_ON_LOAD) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2039
		ctrl_ext = er32(CTRL_EXT);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2040
		ew32(CTRL_EXT, ctrl_ext | E1000_CTRL_EXT_DRV_LOAD);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2041
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2042
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2043
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2044
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2045
 * e1000_release_hw_control - release control of the h/w to f/w
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2046
 * @adapter: address of board private structure
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2047
 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2048
 * e1000_release_hw_control resets {CTRL_EXT|SWSM}:DRV_LOAD bit.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2049
 * For ASF and Pass Through versions of f/w this means that the
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2050
 * driver is no longer loaded. For AMT version (only with 82573) i
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2051
 * of the f/w this means that the network i/f is closed.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2052
 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2053
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2054
static void e1000_release_hw_control(struct e1000_adapter *adapter)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2055
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2056
	struct e1000_hw *hw = &adapter->hw;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2057
	u32 ctrl_ext;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2058
	u32 swsm;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2059
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2060
	/* Let firmware taken over control of h/w */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2061
	if (adapter->flags & FLAG_HAS_SWSM_ON_LOAD) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2062
		swsm = er32(SWSM);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2063
		ew32(SWSM, swsm & ~E1000_SWSM_DRV_LOAD);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2064
	} else if (adapter->flags & FLAG_HAS_CTRLEXT_ON_LOAD) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2065
		ctrl_ext = er32(CTRL_EXT);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2066
		ew32(CTRL_EXT, ctrl_ext & ~E1000_CTRL_EXT_DRV_LOAD);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2067
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2068
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2069
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2070
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2071
 * @e1000_alloc_ring - allocate memory for a ring structure
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2072
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2073
static int e1000_alloc_ring_dma(struct e1000_adapter *adapter,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2074
				struct e1000_ring *ring)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2075
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2076
	struct pci_dev *pdev = adapter->pdev;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2077
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2078
	ring->desc = dma_alloc_coherent(&pdev->dev, ring->size, &ring->dma,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2079
					GFP_KERNEL);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2080
	if (!ring->desc)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2081
		return -ENOMEM;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2082
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2083
	return 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2084
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2085
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2086
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2087
 * e1000e_setup_tx_resources - allocate Tx resources (Descriptors)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2088
 * @adapter: board private structure
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2089
 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2090
 * Return 0 on success, negative on failure
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2091
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2092
int e1000e_setup_tx_resources(struct e1000_adapter *adapter)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2093
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2094
	struct e1000_ring *tx_ring = adapter->tx_ring;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2095
	int err = -ENOMEM, size;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2096
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2097
	size = sizeof(struct e1000_buffer) * tx_ring->count;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2098
	tx_ring->buffer_info = vmalloc(size);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2099
	if (!tx_ring->buffer_info)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2100
		goto err;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2101
	memset(tx_ring->buffer_info, 0, size);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2102
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2103
	/* round up to nearest 4K */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2104
	tx_ring->size = tx_ring->count * sizeof(struct e1000_tx_desc);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2105
	tx_ring->size = ALIGN(tx_ring->size, 4096);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2106
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2107
	err = e1000_alloc_ring_dma(adapter, tx_ring);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2108
	if (err)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2109
		goto err;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2110
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2111
	tx_ring->next_to_use = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2112
	tx_ring->next_to_clean = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2113
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2114
	return 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2115
err:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2116
	vfree(tx_ring->buffer_info);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2117
	e_err("Unable to allocate memory for the transmit descriptor ring\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2118
	return err;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2119
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2120
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2121
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2122
 * e1000e_setup_rx_resources - allocate Rx resources (Descriptors)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2123
 * @adapter: board private structure
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2124
 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2125
 * Returns 0 on success, negative on failure
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2126
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2127
int e1000e_setup_rx_resources(struct e1000_adapter *adapter)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2128
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2129
	struct e1000_ring *rx_ring = adapter->rx_ring;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2130
	struct e1000_buffer *buffer_info;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2131
	int i, size, desc_len, err = -ENOMEM;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2132
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2133
	size = sizeof(struct e1000_buffer) * rx_ring->count;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2134
	rx_ring->buffer_info = vmalloc(size);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2135
	if (!rx_ring->buffer_info)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2136
		goto err;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2137
	memset(rx_ring->buffer_info, 0, size);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2138
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2139
	for (i = 0; i < rx_ring->count; i++) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2140
		buffer_info = &rx_ring->buffer_info[i];
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2141
		buffer_info->ps_pages = kcalloc(PS_PAGE_BUFFERS,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2142
						sizeof(struct e1000_ps_page),
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2143
						GFP_KERNEL);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2144
		if (!buffer_info->ps_pages)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2145
			goto err_pages;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2146
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2147
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2148
	desc_len = sizeof(union e1000_rx_desc_packet_split);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2149
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2150
	/* Round up to nearest 4K */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2151
	rx_ring->size = rx_ring->count * desc_len;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2152
	rx_ring->size = ALIGN(rx_ring->size, 4096);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2153
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2154
	err = e1000_alloc_ring_dma(adapter, rx_ring);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2155
	if (err)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2156
		goto err_pages;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2157
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2158
	rx_ring->next_to_clean = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2159
	rx_ring->next_to_use = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2160
	rx_ring->rx_skb_top = NULL;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2161
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2162
	return 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2163
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2164
err_pages:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2165
	for (i = 0; i < rx_ring->count; i++) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2166
		buffer_info = &rx_ring->buffer_info[i];
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2167
		kfree(buffer_info->ps_pages);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2168
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2169
err:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2170
	vfree(rx_ring->buffer_info);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2171
	e_err("Unable to allocate memory for the transmit descriptor ring\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2172
	return err;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2173
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2174
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2175
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2176
 * e1000_clean_tx_ring - Free Tx Buffers
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2177
 * @adapter: board private structure
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2178
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2179
static void e1000_clean_tx_ring(struct e1000_adapter *adapter)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2180
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2181
	struct e1000_ring *tx_ring = adapter->tx_ring;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2182
	struct e1000_buffer *buffer_info;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2183
	unsigned long size;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2184
	unsigned int i;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2185
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2186
	for (i = 0; i < tx_ring->count; i++) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2187
		buffer_info = &tx_ring->buffer_info[i];
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2188
		e1000_put_txbuf(adapter, buffer_info);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2189
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2190
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2191
	size = sizeof(struct e1000_buffer) * tx_ring->count;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2192
	memset(tx_ring->buffer_info, 0, size);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2193
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2194
	memset(tx_ring->desc, 0, tx_ring->size);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2195
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2196
	tx_ring->next_to_use = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2197
	tx_ring->next_to_clean = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2198
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2199
	writel(0, adapter->hw.hw_addr + tx_ring->head);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2200
	writel(0, adapter->hw.hw_addr + tx_ring->tail);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2201
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2202
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2203
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2204
 * e1000e_free_tx_resources - Free Tx Resources per Queue
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2205
 * @adapter: board private structure
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2206
 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2207
 * Free all transmit software resources
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2208
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2209
void e1000e_free_tx_resources(struct e1000_adapter *adapter)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2210
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2211
	struct pci_dev *pdev = adapter->pdev;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2212
	struct e1000_ring *tx_ring = adapter->tx_ring;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2213
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2214
	e1000_clean_tx_ring(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2215
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2216
	vfree(tx_ring->buffer_info);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2217
	tx_ring->buffer_info = NULL;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2218
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2219
	dma_free_coherent(&pdev->dev, tx_ring->size, tx_ring->desc,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2220
			  tx_ring->dma);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2221
	tx_ring->desc = NULL;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2222
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2223
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2224
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2225
 * e1000e_free_rx_resources - Free Rx Resources
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2226
 * @adapter: board private structure
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2227
 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2228
 * Free all receive software resources
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2229
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2230
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2231
void e1000e_free_rx_resources(struct e1000_adapter *adapter)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2232
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2233
	struct pci_dev *pdev = adapter->pdev;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2234
	struct e1000_ring *rx_ring = adapter->rx_ring;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2235
	int i;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2236
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2237
	e1000_clean_rx_ring(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2238
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2239
	for (i = 0; i < rx_ring->count; i++) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2240
		kfree(rx_ring->buffer_info[i].ps_pages);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2241
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2242
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2243
	vfree(rx_ring->buffer_info);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2244
	rx_ring->buffer_info = NULL;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2245
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2246
	dma_free_coherent(&pdev->dev, rx_ring->size, rx_ring->desc,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2247
			  rx_ring->dma);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2248
	rx_ring->desc = NULL;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2249
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2250
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2251
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2252
 * e1000_update_itr - update the dynamic ITR value based on statistics
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2253
 * @adapter: pointer to adapter
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2254
 * @itr_setting: current adapter->itr
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2255
 * @packets: the number of packets during this measurement interval
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2256
 * @bytes: the number of bytes during this measurement interval
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2257
 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2258
 *      Stores a new ITR value based on packets and byte
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2259
 *      counts during the last interrupt.  The advantage of per interrupt
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2260
 *      computation is faster updates and more accurate ITR for the current
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2261
 *      traffic pattern.  Constants in this function were computed
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2262
 *      based on theoretical maximum wire speed and thresholds were set based
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2263
 *      on testing data as well as attempting to minimize response time
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2264
 *      while increasing bulk throughput.  This functionality is controlled
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2265
 *      by the InterruptThrottleRate module parameter.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2266
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2267
static unsigned int e1000_update_itr(struct e1000_adapter *adapter,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2268
				     u16 itr_setting, int packets,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2269
				     int bytes)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2270
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2271
	unsigned int retval = itr_setting;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2272
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2273
	if (packets == 0)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2274
		goto update_itr_done;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2275
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2276
	switch (itr_setting) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2277
	case lowest_latency:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2278
		/* handle TSO and jumbo frames */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2279
		if (bytes/packets > 8000)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2280
			retval = bulk_latency;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2281
		else if ((packets < 5) && (bytes > 512)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2282
			retval = low_latency;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2283
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2284
		break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2285
	case low_latency:  /* 50 usec aka 20000 ints/s */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2286
		if (bytes > 10000) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2287
			/* this if handles the TSO accounting */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2288
			if (bytes/packets > 8000) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2289
				retval = bulk_latency;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2290
			} else if ((packets < 10) || ((bytes/packets) > 1200)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2291
				retval = bulk_latency;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2292
			} else if ((packets > 35)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2293
				retval = lowest_latency;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2294
			}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2295
		} else if (bytes/packets > 2000) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2296
			retval = bulk_latency;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2297
		} else if (packets <= 2 && bytes < 512) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2298
			retval = lowest_latency;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2299
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2300
		break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2301
	case bulk_latency: /* 250 usec aka 4000 ints/s */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2302
		if (bytes > 25000) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2303
			if (packets > 35) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2304
				retval = low_latency;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2305
			}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2306
		} else if (bytes < 6000) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2307
			retval = low_latency;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2308
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2309
		break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2310
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2311
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2312
update_itr_done:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2313
	return retval;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2314
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2315
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2316
static void e1000_set_itr(struct e1000_adapter *adapter)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2317
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2318
	struct e1000_hw *hw = &adapter->hw;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2319
	u16 current_itr;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2320
	u32 new_itr = adapter->itr;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2321
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2322
	/* for non-gigabit speeds, just fix the interrupt rate at 4000 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2323
	if (adapter->link_speed != SPEED_1000) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2324
		current_itr = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2325
		new_itr = 4000;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2326
		goto set_itr_now;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2327
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2328
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2329
	adapter->tx_itr = e1000_update_itr(adapter,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2330
				    adapter->tx_itr,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2331
				    adapter->total_tx_packets,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2332
				    adapter->total_tx_bytes);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2333
	/* conservative mode (itr 3) eliminates the lowest_latency setting */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2334
	if (adapter->itr_setting == 3 && adapter->tx_itr == lowest_latency)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2335
		adapter->tx_itr = low_latency;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2336
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2337
	adapter->rx_itr = e1000_update_itr(adapter,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2338
				    adapter->rx_itr,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2339
				    adapter->total_rx_packets,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2340
				    adapter->total_rx_bytes);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2341
	/* conservative mode (itr 3) eliminates the lowest_latency setting */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2342
	if (adapter->itr_setting == 3 && adapter->rx_itr == lowest_latency)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2343
		adapter->rx_itr = low_latency;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2344
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2345
	current_itr = max(adapter->rx_itr, adapter->tx_itr);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2346
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2347
	switch (current_itr) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2348
	/* counts and packets in update_itr are dependent on these numbers */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2349
	case lowest_latency:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2350
		new_itr = 70000;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2351
		break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2352
	case low_latency:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2353
		new_itr = 20000; /* aka hwitr = ~200 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2354
		break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2355
	case bulk_latency:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2356
		new_itr = 4000;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2357
		break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2358
	default:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2359
		break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2360
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2361
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2362
set_itr_now:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2363
	if (new_itr != adapter->itr) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2364
		/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2365
		 * this attempts to bias the interrupt rate towards Bulk
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2366
		 * by adding intermediate steps when interrupt rate is
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2367
		 * increasing
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2368
		 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2369
		new_itr = new_itr > adapter->itr ?
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2370
			     min(adapter->itr + (new_itr >> 2), new_itr) :
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2371
			     new_itr;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2372
		adapter->itr = new_itr;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2373
		adapter->rx_ring->itr_val = new_itr;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2374
		if (adapter->msix_entries)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2375
			adapter->rx_ring->set_itr = 1;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2376
		else
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2377
			ew32(ITR, 1000000000 / (new_itr * 256));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2378
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2379
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2380
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2381
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2382
 * e1000_alloc_queues - Allocate memory for all rings
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2383
 * @adapter: board private structure to initialize
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2384
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2385
static int __devinit e1000_alloc_queues(struct e1000_adapter *adapter)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2386
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2387
	adapter->tx_ring = kzalloc(sizeof(struct e1000_ring), GFP_KERNEL);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2388
	if (!adapter->tx_ring)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2389
		goto err;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2390
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2391
	adapter->rx_ring = kzalloc(sizeof(struct e1000_ring), GFP_KERNEL);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2392
	if (!adapter->rx_ring)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2393
		goto err;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2394
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2395
	return 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2396
err:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2397
	e_err("Unable to allocate memory for queues\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2398
	kfree(adapter->rx_ring);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2399
	kfree(adapter->tx_ring);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2400
	return -ENOMEM;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2401
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2402
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2403
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2404
 * e1000_clean - NAPI Rx polling callback
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2405
 * @napi: struct associated with this polling callback
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2406
 * @budget: amount of packets driver is allowed to process this poll
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2407
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2408
static int e1000_clean(struct napi_struct *napi, int budget)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2409
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2410
	struct e1000_adapter *adapter = container_of(napi, struct e1000_adapter, napi);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2411
	struct e1000_hw *hw = &adapter->hw;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2412
	struct net_device *poll_dev = adapter->netdev;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2413
	int tx_cleaned = 1, work_done = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2414
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2415
	adapter = netdev_priv(poll_dev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2416
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2417
	if (adapter->msix_entries &&
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2418
	    !(adapter->rx_ring->ims_val & adapter->tx_ring->ims_val))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2419
		goto clean_rx;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2420
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2421
	tx_cleaned = e1000_clean_tx_irq(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2422
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2423
clean_rx:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2424
	adapter->clean_rx(adapter, &work_done, budget);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2425
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2426
	if (!tx_cleaned)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2427
		work_done = budget;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2428
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2429
	/* If budget not fully consumed, exit the polling mode */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2430
	if (work_done < budget) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2431
		if (adapter->itr_setting & 3)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2432
			e1000_set_itr(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2433
		napi_complete(napi);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2434
		if (!test_bit(__E1000_DOWN, &adapter->state)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2435
			if (adapter->msix_entries)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2436
				ew32(IMS, adapter->rx_ring->ims_val);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2437
			else
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2438
				e1000_irq_enable(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2439
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2440
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2441
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2442
	return work_done;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2443
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2444
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2445
static void e1000_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2446
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2447
	struct e1000_adapter *adapter = netdev_priv(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2448
	struct e1000_hw *hw = &adapter->hw;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2449
	u32 vfta, index;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2450
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2451
	/* don't update vlan cookie if already programmed */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2452
	if ((adapter->hw.mng_cookie.status &
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2453
	     E1000_MNG_DHCP_COOKIE_STATUS_VLAN) &&
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2454
	    (vid == adapter->mng_vlan_id))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2455
		return;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2456
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2457
	/* add VID to filter table */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2458
	if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2459
		index = (vid >> 5) & 0x7F;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2460
		vfta = E1000_READ_REG_ARRAY(hw, E1000_VFTA, index);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2461
		vfta |= (1 << (vid & 0x1F));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2462
		hw->mac.ops.write_vfta(hw, index, vfta);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2463
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2464
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2465
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2466
static void e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2467
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2468
	struct e1000_adapter *adapter = netdev_priv(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2469
	struct e1000_hw *hw = &adapter->hw;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2470
	u32 vfta, index;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2471
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2472
	if (!test_bit(__E1000_DOWN, &adapter->state))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2473
		e1000_irq_disable(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2474
	vlan_group_set_device(adapter->vlgrp, vid, NULL);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2475
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2476
	if (!test_bit(__E1000_DOWN, &adapter->state))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2477
		e1000_irq_enable(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2478
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2479
	if ((adapter->hw.mng_cookie.status &
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2480
	     E1000_MNG_DHCP_COOKIE_STATUS_VLAN) &&
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2481
	    (vid == adapter->mng_vlan_id)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2482
		/* release control to f/w */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2483
		e1000_release_hw_control(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2484
		return;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2485
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2486
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2487
	/* remove VID from filter table */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2488
	if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2489
		index = (vid >> 5) & 0x7F;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2490
		vfta = E1000_READ_REG_ARRAY(hw, E1000_VFTA, index);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2491
		vfta &= ~(1 << (vid & 0x1F));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2492
		hw->mac.ops.write_vfta(hw, index, vfta);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2493
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2494
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2495
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2496
static void e1000_update_mng_vlan(struct e1000_adapter *adapter)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2497
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2498
	struct net_device *netdev = adapter->netdev;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2499
	u16 vid = adapter->hw.mng_cookie.vlan_id;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2500
	u16 old_vid = adapter->mng_vlan_id;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2501
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2502
	if (!adapter->vlgrp)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2503
		return;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2504
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2505
	if (!vlan_group_get_device(adapter->vlgrp, vid)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2506
		adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2507
		if (adapter->hw.mng_cookie.status &
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2508
			E1000_MNG_DHCP_COOKIE_STATUS_VLAN) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2509
			e1000_vlan_rx_add_vid(netdev, vid);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2510
			adapter->mng_vlan_id = vid;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2511
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2512
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2513
		if ((old_vid != (u16)E1000_MNG_VLAN_NONE) &&
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2514
				(vid != old_vid) &&
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2515
		    !vlan_group_get_device(adapter->vlgrp, old_vid))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2516
			e1000_vlan_rx_kill_vid(netdev, old_vid);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2517
	} else {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2518
		adapter->mng_vlan_id = vid;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2519
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2520
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2521
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2522
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2523
static void e1000_vlan_rx_register(struct net_device *netdev,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2524
				   struct vlan_group *grp)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2525
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2526
	struct e1000_adapter *adapter = netdev_priv(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2527
	struct e1000_hw *hw = &adapter->hw;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2528
	u32 ctrl, rctl;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2529
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2530
	if (!test_bit(__E1000_DOWN, &adapter->state))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2531
		e1000_irq_disable(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2532
	adapter->vlgrp = grp;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2533
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2534
	if (grp) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2535
		/* enable VLAN tag insert/strip */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2536
		ctrl = er32(CTRL);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2537
		ctrl |= E1000_CTRL_VME;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2538
		ew32(CTRL, ctrl);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2539
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2540
		if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2541
			/* enable VLAN receive filtering */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2542
			rctl = er32(RCTL);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2543
			rctl &= ~E1000_RCTL_CFIEN;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2544
			ew32(RCTL, rctl);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2545
			e1000_update_mng_vlan(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2546
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2547
	} else {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2548
		/* disable VLAN tag insert/strip */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2549
		ctrl = er32(CTRL);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2550
		ctrl &= ~E1000_CTRL_VME;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2551
		ew32(CTRL, ctrl);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2552
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2553
		if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2554
			if (adapter->mng_vlan_id !=
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2555
			    (u16)E1000_MNG_VLAN_NONE) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2556
				e1000_vlan_rx_kill_vid(netdev,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2557
						       adapter->mng_vlan_id);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2558
				adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2559
			}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2560
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2561
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2562
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2563
	if (!test_bit(__E1000_DOWN, &adapter->state))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2564
		e1000_irq_enable(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2565
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2566
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2567
static void e1000_restore_vlan(struct e1000_adapter *adapter)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2568
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2569
	u16 vid;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2570
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2571
	e1000_vlan_rx_register(adapter->netdev, adapter->vlgrp);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2572
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2573
	if (!adapter->vlgrp)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2574
		return;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2575
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2576
	for (vid = 0; vid < VLAN_GROUP_ARRAY_LEN; vid++) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2577
		if (!vlan_group_get_device(adapter->vlgrp, vid))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2578
			continue;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2579
		e1000_vlan_rx_add_vid(adapter->netdev, vid);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2580
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2581
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2582
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2583
static void e1000_init_manageability_pt(struct e1000_adapter *adapter)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2584
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2585
	struct e1000_hw *hw = &adapter->hw;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2586
	u32 manc, manc2h, mdef, i, j;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2587
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2588
	if (!(adapter->flags & FLAG_MNG_PT_ENABLED))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2589
		return;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2590
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2591
	manc = er32(MANC);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2592
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2593
	/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2594
	 * enable receiving management packets to the host. this will probably
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2595
	 * generate destination unreachable messages from the host OS, but
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2596
	 * the packets will be handled on SMBUS
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2597
	 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2598
	manc |= E1000_MANC_EN_MNG2HOST;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2599
	manc2h = er32(MANC2H);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2600
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2601
	switch (hw->mac.type) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2602
	default:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2603
		manc2h |= (E1000_MANC2H_PORT_623 | E1000_MANC2H_PORT_664);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2604
		break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2605
	case e1000_82574:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2606
	case e1000_82583:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2607
		/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2608
		 * Check if IPMI pass-through decision filter already exists;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2609
		 * if so, enable it.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2610
		 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2611
		for (i = 0, j = 0; i < 8; i++) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2612
			mdef = er32(MDEF(i));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2613
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2614
			/* Ignore filters with anything other than IPMI ports */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2615
			if (mdef & ~(E1000_MDEF_PORT_623 | E1000_MDEF_PORT_664))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2616
				continue;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2617
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2618
			/* Enable this decision filter in MANC2H */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2619
			if (mdef)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2620
				manc2h |= (1 << i);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2621
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2622
			j |= mdef;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2623
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2624
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2625
		if (j == (E1000_MDEF_PORT_623 | E1000_MDEF_PORT_664))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2626
			break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2627
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2628
		/* Create new decision filter in an empty filter */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2629
		for (i = 0, j = 0; i < 8; i++)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2630
			if (er32(MDEF(i)) == 0) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2631
				ew32(MDEF(i), (E1000_MDEF_PORT_623 |
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2632
					       E1000_MDEF_PORT_664));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2633
				manc2h |= (1 << 1);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2634
				j++;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2635
				break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2636
			}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2637
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2638
		if (!j)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2639
			e_warn("Unable to create IPMI pass-through filter\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2640
		break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2641
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2642
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2643
	ew32(MANC2H, manc2h);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2644
	ew32(MANC, manc);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2645
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2646
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2647
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2648
 * e1000_configure_tx - Configure 8254x Transmit Unit after Reset
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2649
 * @adapter: board private structure
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2650
 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2651
 * Configure the Tx unit of the MAC after a reset.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2652
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2653
static void e1000_configure_tx(struct e1000_adapter *adapter)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2654
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2655
	struct e1000_hw *hw = &adapter->hw;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2656
	struct e1000_ring *tx_ring = adapter->tx_ring;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2657
	u64 tdba;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2658
	u32 tdlen, tctl, tipg, tarc;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2659
	u32 ipgr1, ipgr2;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2660
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2661
	/* Setup the HW Tx Head and Tail descriptor pointers */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2662
	tdba = tx_ring->dma;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2663
	tdlen = tx_ring->count * sizeof(struct e1000_tx_desc);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2664
	ew32(TDBAL, (tdba & DMA_BIT_MASK(32)));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2665
	ew32(TDBAH, (tdba >> 32));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2666
	ew32(TDLEN, tdlen);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2667
	ew32(TDH, 0);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2668
	ew32(TDT, 0);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2669
	tx_ring->head = E1000_TDH;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2670
	tx_ring->tail = E1000_TDT;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2671
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2672
	/* Set the default values for the Tx Inter Packet Gap timer */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2673
	tipg = DEFAULT_82543_TIPG_IPGT_COPPER;          /*  8  */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2674
	ipgr1 = DEFAULT_82543_TIPG_IPGR1;               /*  8  */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2675
	ipgr2 = DEFAULT_82543_TIPG_IPGR2;               /*  6  */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2676
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2677
	if (adapter->flags & FLAG_TIPG_MEDIUM_FOR_80003ESLAN)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2678
		ipgr2 = DEFAULT_80003ES2LAN_TIPG_IPGR2; /*  7  */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2679
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2680
	tipg |= ipgr1 << E1000_TIPG_IPGR1_SHIFT;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2681
	tipg |= ipgr2 << E1000_TIPG_IPGR2_SHIFT;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2682
	ew32(TIPG, tipg);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2683
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2684
	/* Set the Tx Interrupt Delay register */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2685
	ew32(TIDV, adapter->tx_int_delay);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2686
	/* Tx irq moderation */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2687
	ew32(TADV, adapter->tx_abs_int_delay);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2688
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2689
	/* Program the Transmit Control Register */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2690
	tctl = er32(TCTL);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2691
	tctl &= ~E1000_TCTL_CT;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2692
	tctl |= E1000_TCTL_PSP | E1000_TCTL_RTLC |
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2693
		(E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2694
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2695
	if (adapter->flags & FLAG_TARC_SPEED_MODE_BIT) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2696
		tarc = er32(TARC(0));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2697
		/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2698
		 * set the speed mode bit, we'll clear it if we're not at
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2699
		 * gigabit link later
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2700
		 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2701
#define SPEED_MODE_BIT (1 << 21)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2702
		tarc |= SPEED_MODE_BIT;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2703
		ew32(TARC(0), tarc);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2704
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2705
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2706
	/* errata: program both queues to unweighted RR */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2707
	if (adapter->flags & FLAG_TARC_SET_BIT_ZERO) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2708
		tarc = er32(TARC(0));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2709
		tarc |= 1;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2710
		ew32(TARC(0), tarc);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2711
		tarc = er32(TARC(1));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2712
		tarc |= 1;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2713
		ew32(TARC(1), tarc);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2714
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2715
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2716
	/* Setup Transmit Descriptor Settings for eop descriptor */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2717
	adapter->txd_cmd = E1000_TXD_CMD_EOP | E1000_TXD_CMD_IFCS;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2718
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2719
	/* only set IDE if we are delaying interrupts using the timers */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2720
	if (adapter->tx_int_delay)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2721
		adapter->txd_cmd |= E1000_TXD_CMD_IDE;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2722
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2723
	/* enable Report Status bit */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2724
	adapter->txd_cmd |= E1000_TXD_CMD_RS;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2725
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2726
	ew32(TCTL, tctl);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2727
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2728
	e1000e_config_collision_dist(hw);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2729
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2730
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2731
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2732
 * e1000_setup_rctl - configure the receive control registers
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2733
 * @adapter: Board private structure
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2734
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2735
#define PAGE_USE_COUNT(S) (((S) >> PAGE_SHIFT) + \
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2736
			   (((S) & (PAGE_SIZE - 1)) ? 1 : 0))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2737
static void e1000_setup_rctl(struct e1000_adapter *adapter)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2738
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2739
	struct e1000_hw *hw = &adapter->hw;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2740
	u32 rctl, rfctl;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2741
	u32 psrctl = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2742
	u32 pages = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2743
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2744
	/* Program MC offset vector base */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2745
	rctl = er32(RCTL);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2746
	rctl &= ~(3 << E1000_RCTL_MO_SHIFT);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2747
	rctl |= E1000_RCTL_EN | E1000_RCTL_BAM |
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2748
		E1000_RCTL_LBM_NO | E1000_RCTL_RDMTS_HALF |
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2749
		(adapter->hw.mac.mc_filter_type << E1000_RCTL_MO_SHIFT);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2750
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2751
	/* Do not Store bad packets */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2752
	rctl &= ~E1000_RCTL_SBP;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2753
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2754
	/* Enable Long Packet receive */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2755
	if (adapter->netdev->mtu <= ETH_DATA_LEN)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2756
		rctl &= ~E1000_RCTL_LPE;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2757
	else
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2758
		rctl |= E1000_RCTL_LPE;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2759
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2760
	/* Some systems expect that the CRC is included in SMBUS traffic. The
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2761
	 * hardware strips the CRC before sending to both SMBUS (BMC) and to
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2762
	 * host memory when this is enabled
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2763
	 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2764
	if (adapter->flags2 & FLAG2_CRC_STRIPPING)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2765
		rctl |= E1000_RCTL_SECRC;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2766
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2767
	/* Workaround Si errata on 82577 PHY - configure IPG for jumbos */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2768
	if ((hw->phy.type == e1000_phy_82577) && (rctl & E1000_RCTL_LPE)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2769
		u16 phy_data;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2770
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2771
		e1e_rphy(hw, PHY_REG(770, 26), &phy_data);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2772
		phy_data &= 0xfff8;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2773
		phy_data |= (1 << 2);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2774
		e1e_wphy(hw, PHY_REG(770, 26), phy_data);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2775
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2776
		e1e_rphy(hw, 22, &phy_data);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2777
		phy_data &= 0x0fff;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2778
		phy_data |= (1 << 14);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2779
		e1e_wphy(hw, 0x10, 0x2823);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2780
		e1e_wphy(hw, 0x11, 0x0003);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2781
		e1e_wphy(hw, 22, phy_data);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2782
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2783
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2784
	/* Setup buffer sizes */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2785
	rctl &= ~E1000_RCTL_SZ_4096;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2786
	rctl |= E1000_RCTL_BSEX;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2787
	switch (adapter->rx_buffer_len) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2788
	case 2048:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2789
	default:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2790
		rctl |= E1000_RCTL_SZ_2048;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2791
		rctl &= ~E1000_RCTL_BSEX;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2792
		break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2793
	case 4096:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2794
		rctl |= E1000_RCTL_SZ_4096;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2795
		break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2796
	case 8192:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2797
		rctl |= E1000_RCTL_SZ_8192;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2798
		break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2799
	case 16384:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2800
		rctl |= E1000_RCTL_SZ_16384;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2801
		break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2802
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2803
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2804
	/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2805
	 * 82571 and greater support packet-split where the protocol
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2806
	 * header is placed in skb->data and the packet data is
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2807
	 * placed in pages hanging off of skb_shinfo(skb)->nr_frags.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2808
	 * In the case of a non-split, skb->data is linearly filled,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2809
	 * followed by the page buffers.  Therefore, skb->data is
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2810
	 * sized to hold the largest protocol header.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2811
	 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2812
	 * allocations using alloc_page take too long for regular MTU
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2813
	 * so only enable packet split for jumbo frames
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2814
	 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2815
	 * Using pages when the page size is greater than 16k wastes
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2816
	 * a lot of memory, since we allocate 3 pages at all times
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2817
	 * per packet.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2818
	 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2819
	pages = PAGE_USE_COUNT(adapter->netdev->mtu);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2820
	if (!(adapter->flags & FLAG_IS_ICH) && (pages <= 3) &&
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2821
	    (PAGE_SIZE <= 16384) && (rctl & E1000_RCTL_LPE))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2822
		adapter->rx_ps_pages = pages;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2823
	else
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2824
		adapter->rx_ps_pages = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2825
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2826
	if (adapter->rx_ps_pages) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2827
		/* Configure extra packet-split registers */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2828
		rfctl = er32(RFCTL);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2829
		rfctl |= E1000_RFCTL_EXTEN;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2830
		/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2831
		 * disable packet split support for IPv6 extension headers,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2832
		 * because some malformed IPv6 headers can hang the Rx
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2833
		 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2834
		rfctl |= (E1000_RFCTL_IPV6_EX_DIS |
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2835
			  E1000_RFCTL_NEW_IPV6_EXT_DIS);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2836
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2837
		ew32(RFCTL, rfctl);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2838
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2839
		/* Enable Packet split descriptors */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2840
		rctl |= E1000_RCTL_DTYP_PS;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2841
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2842
		psrctl |= adapter->rx_ps_bsize0 >>
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2843
			E1000_PSRCTL_BSIZE0_SHIFT;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2844
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2845
		switch (adapter->rx_ps_pages) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2846
		case 3:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2847
			psrctl |= PAGE_SIZE <<
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2848
				E1000_PSRCTL_BSIZE3_SHIFT;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2849
		case 2:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2850
			psrctl |= PAGE_SIZE <<
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2851
				E1000_PSRCTL_BSIZE2_SHIFT;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2852
		case 1:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2853
			psrctl |= PAGE_SIZE >>
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2854
				E1000_PSRCTL_BSIZE1_SHIFT;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2855
			break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2856
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2857
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2858
		ew32(PSRCTL, psrctl);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2859
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2860
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2861
	ew32(RCTL, rctl);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2862
	/* just started the receive unit, no need to restart */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2863
	adapter->flags &= ~FLAG_RX_RESTART_NOW;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2864
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2865
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2866
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2867
 * e1000_configure_rx - Configure Receive Unit after Reset
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2868
 * @adapter: board private structure
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2869
 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2870
 * Configure the Rx unit of the MAC after a reset.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2871
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2872
static void e1000_configure_rx(struct e1000_adapter *adapter)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2873
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2874
	struct e1000_hw *hw = &adapter->hw;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2875
	struct e1000_ring *rx_ring = adapter->rx_ring;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2876
	u64 rdba;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2877
	u32 rdlen, rctl, rxcsum, ctrl_ext;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2878
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2879
	if (adapter->rx_ps_pages) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2880
		/* this is a 32 byte descriptor */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2881
		rdlen = rx_ring->count *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2882
			sizeof(union e1000_rx_desc_packet_split);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2883
		adapter->clean_rx = e1000_clean_rx_irq_ps;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2884
		adapter->alloc_rx_buf = e1000_alloc_rx_buffers_ps;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2885
	} else if (adapter->netdev->mtu > ETH_FRAME_LEN + ETH_FCS_LEN) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2886
		rdlen = rx_ring->count * sizeof(struct e1000_rx_desc);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2887
		adapter->clean_rx = e1000_clean_jumbo_rx_irq;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2888
		adapter->alloc_rx_buf = e1000_alloc_jumbo_rx_buffers;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2889
	} else {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2890
		rdlen = rx_ring->count * sizeof(struct e1000_rx_desc);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2891
		adapter->clean_rx = e1000_clean_rx_irq;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2892
		adapter->alloc_rx_buf = e1000_alloc_rx_buffers;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2893
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2894
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2895
	/* disable receives while setting up the descriptors */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2896
	rctl = er32(RCTL);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2897
	ew32(RCTL, rctl & ~E1000_RCTL_EN);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2898
	e1e_flush();
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2899
	msleep(10);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2900
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2901
	/* set the Receive Delay Timer Register */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2902
	ew32(RDTR, adapter->rx_int_delay);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2903
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2904
	/* irq moderation */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2905
	ew32(RADV, adapter->rx_abs_int_delay);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2906
	if (adapter->itr_setting != 0)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2907
		ew32(ITR, 1000000000 / (adapter->itr * 256));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2908
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2909
	ctrl_ext = er32(CTRL_EXT);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2910
	/* Auto-Mask interrupts upon ICR access */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2911
	ctrl_ext |= E1000_CTRL_EXT_IAME;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2912
	ew32(IAM, 0xffffffff);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2913
	ew32(CTRL_EXT, ctrl_ext);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2914
	e1e_flush();
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2915
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2916
	/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2917
	 * Setup the HW Rx Head and Tail Descriptor Pointers and
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2918
	 * the Base and Length of the Rx Descriptor Ring
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2919
	 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2920
	rdba = rx_ring->dma;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2921
	ew32(RDBAL, (rdba & DMA_BIT_MASK(32)));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2922
	ew32(RDBAH, (rdba >> 32));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2923
	ew32(RDLEN, rdlen);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2924
	ew32(RDH, 0);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2925
	ew32(RDT, 0);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2926
	rx_ring->head = E1000_RDH;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2927
	rx_ring->tail = E1000_RDT;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2928
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2929
	/* Enable Receive Checksum Offload for TCP and UDP */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2930
	rxcsum = er32(RXCSUM);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2931
	if (adapter->flags & FLAG_RX_CSUM_ENABLED) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2932
		rxcsum |= E1000_RXCSUM_TUOFL;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2933
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2934
		/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2935
		 * IPv4 payload checksum for UDP fragments must be
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2936
		 * used in conjunction with packet-split.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2937
		 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2938
		if (adapter->rx_ps_pages)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2939
			rxcsum |= E1000_RXCSUM_IPPCSE;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2940
	} else {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2941
		rxcsum &= ~E1000_RXCSUM_TUOFL;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2942
		/* no need to clear IPPCSE as it defaults to 0 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2943
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2944
	ew32(RXCSUM, rxcsum);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2945
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2946
	/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2947
	 * Enable early receives on supported devices, only takes effect when
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2948
	 * packet size is equal or larger than the specified value (in 8 byte
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2949
	 * units), e.g. using jumbo frames when setting to E1000_ERT_2048
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2950
	 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2951
	if (adapter->flags & FLAG_HAS_ERT) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2952
		if (adapter->netdev->mtu > ETH_DATA_LEN) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2953
			u32 rxdctl = er32(RXDCTL(0));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2954
			ew32(RXDCTL(0), rxdctl | 0x3);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2955
			ew32(ERT, E1000_ERT_2048 | (1 << 13));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2956
			/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2957
			 * With jumbo frames and early-receive enabled,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2958
			 * excessive C-state transition latencies result in
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2959
			 * dropped transactions.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2960
			 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2961
			pm_qos_update_request(
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2962
				adapter->netdev->pm_qos_req, 55);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2963
		} else {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2964
			pm_qos_update_request(
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2965
				adapter->netdev->pm_qos_req,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2966
				PM_QOS_DEFAULT_VALUE);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2967
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2968
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2969
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2970
	/* Enable Receives */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2971
	ew32(RCTL, rctl);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2972
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2973
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2974
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2975
 *  e1000_update_mc_addr_list - Update Multicast addresses
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2976
 *  @hw: pointer to the HW structure
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2977
 *  @mc_addr_list: array of multicast addresses to program
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2978
 *  @mc_addr_count: number of multicast addresses to program
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2979
 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2980
 *  Updates the Multicast Table Array.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2981
 *  The caller must have a packed mc_addr_list of multicast addresses.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2982
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2983
static void e1000_update_mc_addr_list(struct e1000_hw *hw, u8 *mc_addr_list,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2984
				      u32 mc_addr_count)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2985
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2986
	hw->mac.ops.update_mc_addr_list(hw, mc_addr_list, mc_addr_count);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2987
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2988
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2989
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2990
 * e1000_set_multi - Multicast and Promiscuous mode set
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2991
 * @netdev: network interface device structure
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2992
 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2993
 * The set_multi entry point is called whenever the multicast address
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2994
 * list or the network interface flags are updated.  This routine is
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2995
 * responsible for configuring the hardware for proper multicast,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2996
 * promiscuous mode, and all-multi behavior.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2997
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2998
static void e1000_set_multi(struct net_device *netdev)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2999
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3000
	struct e1000_adapter *adapter = netdev_priv(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3001
	struct e1000_hw *hw = &adapter->hw;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3002
	struct netdev_hw_addr *ha;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3003
	u8  *mta_list;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3004
	u32 rctl;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3005
	int i;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3006
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3007
	/* Check for Promiscuous and All Multicast modes */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3008
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3009
	rctl = er32(RCTL);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3010
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3011
	if (netdev->flags & IFF_PROMISC) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3012
		rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3013
		rctl &= ~E1000_RCTL_VFE;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3014
	} else {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3015
		if (netdev->flags & IFF_ALLMULTI) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3016
			rctl |= E1000_RCTL_MPE;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3017
			rctl &= ~E1000_RCTL_UPE;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3018
		} else {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3019
			rctl &= ~(E1000_RCTL_UPE | E1000_RCTL_MPE);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3020
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3021
		if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3022
			rctl |= E1000_RCTL_VFE;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3023
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3024
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3025
	ew32(RCTL, rctl);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3026
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3027
	if (!netdev_mc_empty(netdev)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3028
		mta_list = kmalloc(netdev_mc_count(netdev) * 6, GFP_ATOMIC);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3029
		if (!mta_list)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3030
			return;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3031
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3032
		/* prepare a packed array of only addresses. */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3033
		i = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3034
		netdev_for_each_mc_addr(ha, netdev)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3035
			memcpy(mta_list + (i++ * ETH_ALEN), ha->addr, ETH_ALEN);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3036
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3037
		e1000_update_mc_addr_list(hw, mta_list, i);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3038
		kfree(mta_list);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3039
	} else {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3040
		/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3041
		 * if we're called from probe, we might not have
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3042
		 * anything to do here, so clear out the list
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3043
		 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3044
		e1000_update_mc_addr_list(hw, NULL, 0);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3045
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3046
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3047
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3048
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3049
 * e1000_configure - configure the hardware for Rx and Tx
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3050
 * @adapter: private board structure
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3051
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3052
static void e1000_configure(struct e1000_adapter *adapter)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3053
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3054
	e1000_set_multi(adapter->netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3055
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3056
	e1000_restore_vlan(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3057
	e1000_init_manageability_pt(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3058
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3059
	e1000_configure_tx(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3060
	e1000_setup_rctl(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3061
	e1000_configure_rx(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3062
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3063
	if (adapter->ecdev) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3064
		adapter->alloc_rx_buf(adapter, adapter->rx_ring->count);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3065
	} else {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3066
		adapter->alloc_rx_buf(adapter, e1000_desc_unused(adapter->rx_ring));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3067
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3068
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3069
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3070
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3071
 * e1000e_power_up_phy - restore link in case the phy was powered down
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3072
 * @adapter: address of board private structure
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3073
 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3074
 * The phy may be powered down to save power and turn off link when the
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3075
 * driver is unloaded and wake on lan is not enabled (among others)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3076
 * *** this routine MUST be followed by a call to e1000e_reset ***
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3077
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3078
void e1000e_power_up_phy(struct e1000_adapter *adapter)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3079
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3080
	if (adapter->hw.phy.ops.power_up)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3081
		adapter->hw.phy.ops.power_up(&adapter->hw);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3082
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3083
	adapter->hw.mac.ops.setup_link(&adapter->hw);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3084
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3085
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3086
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3087
 * e1000_power_down_phy - Power down the PHY
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3088
 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3089
 * Power down the PHY so no link is implied when interface is down.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3090
 * The PHY cannot be powered down if management or WoL is active.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3091
 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3092
static void e1000_power_down_phy(struct e1000_adapter *adapter)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3093
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3094
	/* WoL is enabled */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3095
	if (adapter->wol)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3096
		return;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3097
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3098
	if (adapter->hw.phy.ops.power_down)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3099
		adapter->hw.phy.ops.power_down(&adapter->hw);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3100
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3101
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3102
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3103
 * e1000e_reset - bring the hardware into a known good state
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3104
 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3105
 * This function boots the hardware and enables some settings that
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3106
 * require a configuration cycle of the hardware - those cannot be
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3107
 * set/changed during runtime. After reset the device needs to be
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3108
 * properly configured for Rx, Tx etc.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3109
 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3110
void e1000e_reset(struct e1000_adapter *adapter)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3111
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3112
	struct e1000_mac_info *mac = &adapter->hw.mac;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3113
	struct e1000_fc_info *fc = &adapter->hw.fc;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3114
	struct e1000_hw *hw = &adapter->hw;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3115
	u32 tx_space, min_tx_space, min_rx_space;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3116
	u32 pba = adapter->pba;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3117
	u16 hwm;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3118
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3119
	/* reset Packet Buffer Allocation to default */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3120
	ew32(PBA, pba);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3121
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3122
	if (adapter->max_frame_size > ETH_FRAME_LEN + ETH_FCS_LEN) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3123
		/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3124
		 * To maintain wire speed transmits, the Tx FIFO should be
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3125
		 * large enough to accommodate two full transmit packets,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3126
		 * rounded up to the next 1KB and expressed in KB.  Likewise,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3127
		 * the Rx FIFO should be large enough to accommodate at least
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3128
		 * one full receive packet and is similarly rounded up and
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3129
		 * expressed in KB.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3130
		 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3131
		pba = er32(PBA);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3132
		/* upper 16 bits has Tx packet buffer allocation size in KB */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3133
		tx_space = pba >> 16;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3134
		/* lower 16 bits has Rx packet buffer allocation size in KB */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3135
		pba &= 0xffff;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3136
		/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3137
		 * the Tx fifo also stores 16 bytes of information about the tx
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3138
		 * but don't include ethernet FCS because hardware appends it
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3139
		 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3140
		min_tx_space = (adapter->max_frame_size +
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3141
				sizeof(struct e1000_tx_desc) -
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3142
				ETH_FCS_LEN) * 2;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3143
		min_tx_space = ALIGN(min_tx_space, 1024);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3144
		min_tx_space >>= 10;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3145
		/* software strips receive CRC, so leave room for it */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3146
		min_rx_space = adapter->max_frame_size;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3147
		min_rx_space = ALIGN(min_rx_space, 1024);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3148
		min_rx_space >>= 10;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3149
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3150
		/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3151
		 * If current Tx allocation is less than the min Tx FIFO size,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3152
		 * and the min Tx FIFO size is less than the current Rx FIFO
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3153
		 * allocation, take space away from current Rx allocation
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3154
		 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3155
		if ((tx_space < min_tx_space) &&
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3156
		    ((min_tx_space - tx_space) < pba)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3157
			pba -= min_tx_space - tx_space;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3158
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3159
			/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3160
			 * if short on Rx space, Rx wins and must trump tx
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3161
			 * adjustment or use Early Receive if available
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3162
			 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3163
			if ((pba < min_rx_space) &&
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3164
			    (!(adapter->flags & FLAG_HAS_ERT)))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3165
				/* ERT enabled in e1000_configure_rx */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3166
				pba = min_rx_space;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3167
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3168
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3169
		ew32(PBA, pba);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3170
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3171
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3172
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3173
	/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3174
	 * flow control settings
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3175
	 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3176
	 * The high water mark must be low enough to fit one full frame
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3177
	 * (or the size used for early receive) above it in the Rx FIFO.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3178
	 * Set it to the lower of:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3179
	 * - 90% of the Rx FIFO size, and
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3180
	 * - the full Rx FIFO size minus the early receive size (for parts
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3181
	 *   with ERT support assuming ERT set to E1000_ERT_2048), or
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3182
	 * - the full Rx FIFO size minus one full frame
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3183
	 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3184
	if (hw->mac.type == e1000_pchlan) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3185
		/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3186
		 * Workaround PCH LOM adapter hangs with certain network
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3187
		 * loads.  If hangs persist, try disabling Tx flow control.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3188
		 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3189
		if (adapter->netdev->mtu > ETH_DATA_LEN) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3190
			fc->high_water = 0x3500;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3191
			fc->low_water  = 0x1500;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3192
		} else {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3193
			fc->high_water = 0x5000;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3194
			fc->low_water  = 0x3000;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3195
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3196
		fc->refresh_time = 0x1000;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3197
	} else {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3198
		if ((adapter->flags & FLAG_HAS_ERT) &&
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3199
		    (adapter->netdev->mtu > ETH_DATA_LEN))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3200
			hwm = min(((pba << 10) * 9 / 10),
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3201
				  ((pba << 10) - (E1000_ERT_2048 << 3)));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3202
		else
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3203
			hwm = min(((pba << 10) * 9 / 10),
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3204
				  ((pba << 10) - adapter->max_frame_size));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3205
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3206
		fc->high_water = hwm & E1000_FCRTH_RTH; /* 8-byte granularity */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3207
		fc->low_water = fc->high_water - 8;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3208
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3209
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3210
	if (adapter->flags & FLAG_DISABLE_FC_PAUSE_TIME)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3211
		fc->pause_time = 0xFFFF;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3212
	else
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3213
		fc->pause_time = E1000_FC_PAUSE_TIME;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3214
	fc->send_xon = 1;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3215
	fc->current_mode = fc->requested_mode;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3216
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3217
	/* Allow time for pending master requests to run */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3218
	mac->ops.reset_hw(hw);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3219
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3220
	/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3221
	 * For parts with AMT enabled, let the firmware know
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3222
	 * that the network interface is in control
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3223
	 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3224
	if (adapter->flags & FLAG_HAS_AMT)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3225
		e1000_get_hw_control(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3226
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3227
	ew32(WUC, 0);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3228
	if (adapter->flags2 & FLAG2_HAS_PHY_WAKEUP)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3229
		e1e_wphy(&adapter->hw, BM_WUC, 0);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3230
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3231
	if (mac->ops.init_hw(hw))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3232
		e_err("Hardware Error\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3233
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3234
	e1000_update_mng_vlan(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3235
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3236
	/* Enable h/w to recognize an 802.1Q VLAN Ethernet packet */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3237
	ew32(VET, ETH_P_8021Q);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3238
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3239
	e1000e_reset_adaptive(hw);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3240
	e1000_get_phy_info(hw);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3241
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3242
	if ((adapter->flags & FLAG_HAS_SMART_POWER_DOWN) &&
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3243
	    !(adapter->flags & FLAG_SMART_POWER_DOWN)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3244
		u16 phy_data = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3245
		/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3246
		 * speed up time to link by disabling smart power down, ignore
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3247
		 * the return value of this function because there is nothing
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3248
		 * different we would do if it failed
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3249
		 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3250
		e1e_rphy(hw, IGP02E1000_PHY_POWER_MGMT, &phy_data);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3251
		phy_data &= ~IGP02E1000_PM_SPD;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3252
		e1e_wphy(hw, IGP02E1000_PHY_POWER_MGMT, phy_data);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3253
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3254
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3255
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3256
int e1000e_up(struct e1000_adapter *adapter)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3257
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3258
	struct e1000_hw *hw = &adapter->hw;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3259
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3260
	/* DMA latency requirement to workaround early-receive/jumbo issue */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3261
	if (adapter->flags & FLAG_HAS_ERT)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3262
		adapter->netdev->pm_qos_req =
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3263
			pm_qos_add_request(PM_QOS_CPU_DMA_LATENCY,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3264
				       PM_QOS_DEFAULT_VALUE);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3265
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3266
	/* hardware has been reset, we need to reload some things */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3267
	e1000_configure(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3268
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3269
	clear_bit(__E1000_DOWN, &adapter->state);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3270
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3271
	if (!adapter->ecdev) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3272
		napi_enable(&adapter->napi);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3273
    }
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3274
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3275
	if (adapter->msix_entries)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3276
		e1000_configure_msix(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3277
	if (!adapter->ecdev) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3278
        e1000_irq_enable(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3279
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3280
        netif_wake_queue(adapter->netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3281
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3282
        /* fire a link change interrupt to start the watchdog */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3283
        if (adapter->msix_entries)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3284
            ew32(ICS, E1000_ICS_LSC | E1000_ICR_OTHER);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3285
        else
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3286
            ew32(ICS, E1000_ICS_LSC);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3287
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3288
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3289
	return 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3290
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3291
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3292
void e1000e_down(struct e1000_adapter *adapter)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3293
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3294
	struct net_device *netdev = adapter->netdev;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3295
	struct e1000_hw *hw = &adapter->hw;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3296
	u32 tctl, rctl;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3297
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3298
	/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3299
	 * signal that we're down so the interrupt handler does not
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3300
	 * reschedule our watchdog timer
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3301
	 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3302
	set_bit(__E1000_DOWN, &adapter->state);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3303
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3304
	/* disable receives in the hardware */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3305
	rctl = er32(RCTL);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3306
	ew32(RCTL, rctl & ~E1000_RCTL_EN);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3307
	/* flush and sleep below */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3308
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3309
	if (!adapter->ecdev) 
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3310
		netif_stop_queue(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3311
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3312
	/* disable transmits in the hardware */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3313
	tctl = er32(TCTL);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3314
	tctl &= ~E1000_TCTL_EN;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3315
	ew32(TCTL, tctl);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3316
	/* flush both disables and wait for them to finish */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3317
	e1e_flush();
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3318
	msleep(10);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3319
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3320
	if (!adapter->ecdev) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3321
		napi_disable(&adapter->napi);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3322
		e1000_irq_disable(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3323
		del_timer_sync(&adapter->watchdog_timer);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3324
		del_timer_sync(&adapter->phy_info_timer);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3325
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3326
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3327
	if (adapter->ecdev) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3328
		ecdev_set_link(adapter->ecdev, 0);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3329
	} else {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3330
		netif_carrier_off(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3331
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3332
	adapter->link_speed = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3333
	adapter->link_duplex = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3334
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3335
	if (!pci_channel_offline(adapter->pdev))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3336
		e1000e_reset(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3337
	e1000_clean_tx_ring(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3338
	e1000_clean_rx_ring(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3339
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3340
	if (adapter->flags & FLAG_HAS_ERT) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3341
		pm_qos_remove_request(
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3342
			      adapter->netdev->pm_qos_req);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3343
		adapter->netdev->pm_qos_req = NULL;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3344
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3345
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3346
	/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3347
	 * TODO: for power management, we could drop the link and
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3348
	 * pci_disable_device here.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3349
	 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3350
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3351
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3352
void e1000e_reinit_locked(struct e1000_adapter *adapter)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3353
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3354
	might_sleep();
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3355
	while (test_and_set_bit(__E1000_RESETTING, &adapter->state))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3356
		msleep(1);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3357
	e1000e_down(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3358
	e1000e_up(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3359
	clear_bit(__E1000_RESETTING, &adapter->state);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3360
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3361
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3362
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3363
 * e1000_sw_init - Initialize general software structures (struct e1000_adapter)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3364
 * @adapter: board private structure to initialize
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3365
 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3366
 * e1000_sw_init initializes the Adapter private data structure.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3367
 * Fields are initialized based on PCI device information and
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3368
 * OS network device settings (MTU size).
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3369
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3370
static int __devinit e1000_sw_init(struct e1000_adapter *adapter)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3371
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3372
	struct net_device *netdev = adapter->netdev;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3373
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3374
	adapter->rx_buffer_len = ETH_FRAME_LEN + VLAN_HLEN + ETH_FCS_LEN;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3375
	adapter->rx_ps_bsize0 = 128;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3376
	adapter->max_frame_size = netdev->mtu + ETH_HLEN + ETH_FCS_LEN;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3377
	adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3378
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3379
	e1000e_set_interrupt_capability(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3380
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3381
	if (e1000_alloc_queues(adapter))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3382
		return -ENOMEM;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3383
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3384
	/* Explicitly disable IRQ since the NIC can be in any state. */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3385
	e1000_irq_disable(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3386
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3387
	set_bit(__E1000_DOWN, &adapter->state);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3388
	return 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3389
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3390
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3391
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3392
 * e1000_intr_msi_test - Interrupt Handler
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3393
 * @irq: interrupt number
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3394
 * @data: pointer to a network interface device structure
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3395
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3396
static irqreturn_t e1000_intr_msi_test(int irq, void *data)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3397
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3398
	struct net_device *netdev = data;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3399
	struct e1000_adapter *adapter = netdev_priv(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3400
	struct e1000_hw *hw = &adapter->hw;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3401
	u32 icr = er32(ICR);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3402
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3403
	e_dbg("icr is %08X\n", icr);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3404
	if (icr & E1000_ICR_RXSEQ) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3405
		adapter->flags &= ~FLAG_MSI_TEST_FAILED;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3406
		wmb();
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3407
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3408
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3409
	return IRQ_HANDLED;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3410
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3411
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3412
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3413
 * e1000_test_msi_interrupt - Returns 0 for successful test
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3414
 * @adapter: board private struct
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3415
 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3416
 * code flow taken from tg3.c
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3417
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3418
static int e1000_test_msi_interrupt(struct e1000_adapter *adapter)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3419
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3420
	struct net_device *netdev = adapter->netdev;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3421
	struct e1000_hw *hw = &adapter->hw;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3422
	int err;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3423
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3424
	/* poll_enable hasn't been called yet, so don't need disable */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3425
	/* clear any pending events */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3426
	er32(ICR);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3427
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3428
	/* free the real vector and request a test handler */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3429
	e1000_free_irq(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3430
	e1000e_reset_interrupt_capability(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3431
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3432
	/* Assume that the test fails, if it succeeds then the test
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3433
	 * MSI irq handler will unset this flag */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3434
	adapter->flags |= FLAG_MSI_TEST_FAILED;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3435
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3436
	err = pci_enable_msi(adapter->pdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3437
	if (err)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3438
		goto msi_test_failed;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3439
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3440
	err = request_irq(adapter->pdev->irq, e1000_intr_msi_test, 0,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3441
			  netdev->name, netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3442
	if (err) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3443
		pci_disable_msi(adapter->pdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3444
		goto msi_test_failed;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3445
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3446
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3447
	wmb();
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3448
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3449
	e1000_irq_enable(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3450
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3451
	/* fire an unusual interrupt on the test handler */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3452
	ew32(ICS, E1000_ICS_RXSEQ);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3453
	e1e_flush();
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3454
	msleep(50);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3455
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3456
	e1000_irq_disable(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3457
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3458
	rmb();
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3459
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3460
	if (adapter->flags & FLAG_MSI_TEST_FAILED) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3461
		adapter->int_mode = E1000E_INT_MODE_LEGACY;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3462
		err = -EIO;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3463
		e_info("MSI interrupt test failed!\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3464
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3465
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3466
	free_irq(adapter->pdev->irq, netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3467
	pci_disable_msi(adapter->pdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3468
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3469
	if (err == -EIO)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3470
		goto msi_test_failed;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3471
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3472
	/* okay so the test worked, restore settings */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3473
	e_dbg("MSI interrupt test succeeded!\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3474
msi_test_failed:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3475
	e1000e_set_interrupt_capability(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3476
	e1000_request_irq(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3477
	return err;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3478
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3479
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3480
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3481
 * e1000_test_msi - Returns 0 if MSI test succeeds or INTx mode is restored
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3482
 * @adapter: board private struct
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3483
 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3484
 * code flow taken from tg3.c, called with e1000 interrupts disabled.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3485
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3486
static int e1000_test_msi(struct e1000_adapter *adapter)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3487
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3488
	int err;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3489
	u16 pci_cmd;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3490
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3491
	if (!(adapter->flags & FLAG_MSI_ENABLED))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3492
		return 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3493
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3494
	/* disable SERR in case the MSI write causes a master abort */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3495
	pci_read_config_word(adapter->pdev, PCI_COMMAND, &pci_cmd);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3496
	if (pci_cmd & PCI_COMMAND_SERR)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3497
		pci_write_config_word(adapter->pdev, PCI_COMMAND,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3498
				      pci_cmd & ~PCI_COMMAND_SERR);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3499
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3500
	err = e1000_test_msi_interrupt(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3501
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3502
	/* re-enable SERR */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3503
	if (pci_cmd & PCI_COMMAND_SERR) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3504
		pci_read_config_word(adapter->pdev, PCI_COMMAND, &pci_cmd);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3505
		pci_cmd |= PCI_COMMAND_SERR;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3506
		pci_write_config_word(adapter->pdev, PCI_COMMAND, pci_cmd);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3507
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3508
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3509
	/* success ! */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3510
	if (!err)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3511
		return 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3512
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3513
	/* EIO means MSI test failed */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3514
	if (err != -EIO)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3515
		return err;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3516
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3517
	/* back to INTx mode */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3518
	e_warn("MSI interrupt test failed, using legacy interrupt.\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3519
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3520
	e1000_free_irq(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3521
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3522
	err = e1000_request_irq(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3523
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3524
	return err;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3525
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3526
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3527
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3528
 * e1000_open - Called when a network interface is made active
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3529
 * @netdev: network interface device structure
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3530
 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3531
 * Returns 0 on success, negative value on failure
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3532
 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3533
 * The open entry point is called when a network interface is made
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3534
 * active by the system (IFF_UP).  At this point all resources needed
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3535
 * for transmit and receive operations are allocated, the interrupt
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3536
 * handler is registered with the OS, the watchdog timer is started,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3537
 * and the stack is notified that the interface is ready.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3538
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3539
static int e1000_open(struct net_device *netdev)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3540
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3541
	struct e1000_adapter *adapter = netdev_priv(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3542
	struct e1000_hw *hw = &adapter->hw;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3543
	struct pci_dev *pdev = adapter->pdev;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3544
	int err;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3545
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3546
	/* disallow open during test */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3547
	if (test_bit(__E1000_TESTING, &adapter->state))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3548
		return -EBUSY;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3549
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3550
	pm_runtime_get_sync(&pdev->dev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3551
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3552
	if (adapter->ecdev) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3553
		ecdev_set_link(adapter->ecdev, 0);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3554
	} else {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3555
		netif_carrier_off(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3556
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3557
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3558
	/* allocate transmit descriptors */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3559
	err = e1000e_setup_tx_resources(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3560
	if (err)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3561
		goto err_setup_tx;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3562
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3563
	/* allocate receive descriptors */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3564
	err = e1000e_setup_rx_resources(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3565
	if (err)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3566
		goto err_setup_rx;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3567
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3568
	/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3569
	 * If AMT is enabled, let the firmware know that the network
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3570
	 * interface is now open and reset the part to a known state.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3571
	 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3572
	if (adapter->flags & FLAG_HAS_AMT) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3573
		e1000_get_hw_control(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3574
		e1000e_reset(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3575
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3576
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3577
	e1000e_power_up_phy(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3578
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3579
	adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3580
	if ((adapter->hw.mng_cookie.status &
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3581
	     E1000_MNG_DHCP_COOKIE_STATUS_VLAN))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3582
		e1000_update_mng_vlan(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3583
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3584
	/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3585
	 * before we allocate an interrupt, we must be ready to handle it.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3586
	 * Setting DEBUG_SHIRQ in the kernel makes it fire an interrupt
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3587
	 * as soon as we call pci_request_irq, so we have to setup our
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3588
	 * clean_rx handler before we do so.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3589
	 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3590
	e1000_configure(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3591
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3592
	err = e1000_request_irq(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3593
	if (err)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3594
		goto err_req_irq;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3595
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3596
	/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3597
	 * Work around PCIe errata with MSI interrupts causing some chipsets to
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3598
	 * ignore e1000e MSI messages, which means we need to test our MSI
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3599
	 * interrupt now
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3600
	 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3601
	if (adapter->int_mode != E1000E_INT_MODE_LEGACY) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3602
		err = e1000_test_msi(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3603
		if (err) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3604
			e_err("Interrupt allocation failed\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3605
			goto err_req_irq;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3606
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3607
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3608
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3609
	/* From here on the code is the same as e1000e_up() */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3610
	clear_bit(__E1000_DOWN, &adapter->state);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3611
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3612
	napi_enable(&adapter->napi);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3613
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3614
	e1000_irq_enable(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3615
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3616
	netif_start_queue(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3617
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3618
	adapter->idle_check = true;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3619
	pm_runtime_put(&pdev->dev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3620
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3621
	/* fire a link status change interrupt to start the watchdog */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3622
	if (adapter->msix_entries)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3623
		ew32(ICS, E1000_ICS_LSC | E1000_ICR_OTHER);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3624
	else
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3625
		ew32(ICS, E1000_ICS_LSC);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3626
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3627
	return 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3628
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3629
err_req_irq:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3630
	e1000_release_hw_control(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3631
	e1000_power_down_phy(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3632
	e1000e_free_rx_resources(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3633
err_setup_rx:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3634
	e1000e_free_tx_resources(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3635
err_setup_tx:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3636
	e1000e_reset(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3637
	pm_runtime_put_sync(&pdev->dev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3638
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3639
	return err;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3640
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3641
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3642
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3643
 * e1000_close - Disables a network interface
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3644
 * @netdev: network interface device structure
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3645
 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3646
 * Returns 0, this is not allowed to fail
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3647
 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3648
 * The close entry point is called when an interface is de-activated
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3649
 * by the OS.  The hardware is still under the drivers control, but
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3650
 * needs to be disabled.  A global MAC reset is issued to stop the
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3651
 * hardware, and all transmit and receive resources are freed.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3652
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3653
static int e1000_close(struct net_device *netdev)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3654
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3655
	struct e1000_adapter *adapter = netdev_priv(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3656
	struct pci_dev *pdev = adapter->pdev;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3657
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3658
	WARN_ON(test_bit(__E1000_RESETTING, &adapter->state));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3659
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3660
	pm_runtime_get_sync(&pdev->dev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3661
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3662
	if (!test_bit(__E1000_DOWN, &adapter->state)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3663
		e1000e_down(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3664
		e1000_free_irq(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3665
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3666
	e1000_power_down_phy(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3667
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3668
	e1000e_free_tx_resources(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3669
	e1000e_free_rx_resources(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3670
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3671
	/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3672
	 * kill manageability vlan ID if supported, but not if a vlan with
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3673
	 * the same ID is registered on the host OS (let 8021q kill it)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3674
	 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3675
	if ((adapter->hw.mng_cookie.status &
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3676
			  E1000_MNG_DHCP_COOKIE_STATUS_VLAN) &&
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3677
	     !(adapter->vlgrp &&
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3678
	       vlan_group_get_device(adapter->vlgrp, adapter->mng_vlan_id)))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3679
		e1000_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3680
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3681
	/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3682
	 * If AMT is enabled, let the firmware know that the network
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3683
	 * interface is now closed
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3684
	 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3685
	if (adapter->flags & FLAG_HAS_AMT)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3686
		e1000_release_hw_control(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3687
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3688
	pm_runtime_put_sync(&pdev->dev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3689
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3690
	return 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3691
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3692
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3693
 * e1000_set_mac - Change the Ethernet Address of the NIC
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3694
 * @netdev: network interface device structure
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3695
 * @p: pointer to an address structure
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3696
 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3697
 * Returns 0 on success, negative on failure
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3698
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3699
static int e1000_set_mac(struct net_device *netdev, void *p)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3700
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3701
	struct e1000_adapter *adapter = netdev_priv(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3702
	struct sockaddr *addr = p;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3703
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3704
	if (!is_valid_ether_addr(addr->sa_data))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3705
		return -EADDRNOTAVAIL;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3706
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3707
	memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3708
	memcpy(adapter->hw.mac.addr, addr->sa_data, netdev->addr_len);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3709
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3710
	e1000e_rar_set(&adapter->hw, adapter->hw.mac.addr, 0);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3711
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3712
	if (adapter->flags & FLAG_RESET_OVERWRITES_LAA) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3713
		/* activate the work around */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3714
		e1000e_set_laa_state_82571(&adapter->hw, 1);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3715
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3716
		/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3717
		 * Hold a copy of the LAA in RAR[14] This is done so that
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3718
		 * between the time RAR[0] gets clobbered  and the time it
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3719
		 * gets fixed (in e1000_watchdog), the actual LAA is in one
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3720
		 * of the RARs and no incoming packets directed to this port
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3721
		 * are dropped. Eventually the LAA will be in RAR[0] and
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3722
		 * RAR[14]
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3723
		 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3724
		e1000e_rar_set(&adapter->hw,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3725
			      adapter->hw.mac.addr,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3726
			      adapter->hw.mac.rar_entry_count - 1);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3727
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3728
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3729
	return 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3730
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3731
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3732
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3733
 * e1000e_update_phy_task - work thread to update phy
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3734
 * @work: pointer to our work struct
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3735
 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3736
 * this worker thread exists because we must acquire a
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3737
 * semaphore to read the phy, which we could msleep while
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3738
 * waiting for it, and we can't msleep in a timer.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3739
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3740
static void e1000e_update_phy_task(struct work_struct *work)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3741
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3742
	struct e1000_adapter *adapter = container_of(work,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3743
					struct e1000_adapter, update_phy_task);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3744
	e1000_get_phy_info(&adapter->hw);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3745
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3746
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3747
/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3748
 * Need to wait a few seconds after link up to get diagnostic information from
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3749
 * the phy
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3750
 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3751
static void e1000_update_phy_info(unsigned long data)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3752
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3753
	struct e1000_adapter *adapter = (struct e1000_adapter *) data;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3754
	schedule_work(&adapter->update_phy_task);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3755
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3756
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3757
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3758
 * e1000e_update_stats - Update the board statistics counters
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3759
 * @adapter: board private structure
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3760
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3761
void e1000e_update_stats(struct e1000_adapter *adapter)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3762
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3763
	struct net_device *netdev = adapter->netdev;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3764
	struct e1000_hw *hw = &adapter->hw;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3765
	struct pci_dev *pdev = adapter->pdev;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3766
	u16 phy_data;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3767
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3768
	/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3769
	 * Prevent stats update while adapter is being reset, or if the pci
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3770
	 * connection is down.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3771
	 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3772
	if (adapter->link_speed == 0)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3773
		return;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3774
	if (pci_channel_offline(pdev))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3775
		return;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3776
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3777
	adapter->stats.crcerrs += er32(CRCERRS);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3778
	adapter->stats.gprc += er32(GPRC);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3779
	adapter->stats.gorc += er32(GORCL);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3780
	er32(GORCH); /* Clear gorc */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3781
	adapter->stats.bprc += er32(BPRC);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3782
	adapter->stats.mprc += er32(MPRC);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3783
	adapter->stats.roc += er32(ROC);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3784
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3785
	adapter->stats.mpc += er32(MPC);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3786
	if ((hw->phy.type == e1000_phy_82578) ||
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3787
	    (hw->phy.type == e1000_phy_82577)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3788
		e1e_rphy(hw, HV_SCC_UPPER, &phy_data);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3789
		if (!e1e_rphy(hw, HV_SCC_LOWER, &phy_data))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3790
			adapter->stats.scc += phy_data;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3791
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3792
		e1e_rphy(hw, HV_ECOL_UPPER, &phy_data);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3793
		if (!e1e_rphy(hw, HV_ECOL_LOWER, &phy_data))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3794
			adapter->stats.ecol += phy_data;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3795
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3796
		e1e_rphy(hw, HV_MCC_UPPER, &phy_data);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3797
		if (!e1e_rphy(hw, HV_MCC_LOWER, &phy_data))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3798
			adapter->stats.mcc += phy_data;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3799
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3800
		e1e_rphy(hw, HV_LATECOL_UPPER, &phy_data);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3801
		if (!e1e_rphy(hw, HV_LATECOL_LOWER, &phy_data))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3802
			adapter->stats.latecol += phy_data;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3803
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3804
		e1e_rphy(hw, HV_DC_UPPER, &phy_data);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3805
		if (!e1e_rphy(hw, HV_DC_LOWER, &phy_data))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3806
			adapter->stats.dc += phy_data;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3807
	} else {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3808
		adapter->stats.scc += er32(SCC);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3809
		adapter->stats.ecol += er32(ECOL);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3810
		adapter->stats.mcc += er32(MCC);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3811
		adapter->stats.latecol += er32(LATECOL);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3812
		adapter->stats.dc += er32(DC);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3813
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3814
	adapter->stats.xonrxc += er32(XONRXC);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3815
	adapter->stats.xontxc += er32(XONTXC);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3816
	adapter->stats.xoffrxc += er32(XOFFRXC);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3817
	adapter->stats.xofftxc += er32(XOFFTXC);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3818
	adapter->stats.gptc += er32(GPTC);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3819
	adapter->stats.gotc += er32(GOTCL);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3820
	er32(GOTCH); /* Clear gotc */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3821
	adapter->stats.rnbc += er32(RNBC);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3822
	adapter->stats.ruc += er32(RUC);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3823
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3824
	adapter->stats.mptc += er32(MPTC);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3825
	adapter->stats.bptc += er32(BPTC);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3826
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3827
	/* used for adaptive IFS */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3828
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3829
	hw->mac.tx_packet_delta = er32(TPT);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3830
	adapter->stats.tpt += hw->mac.tx_packet_delta;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3831
	if ((hw->phy.type == e1000_phy_82578) ||
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3832
	    (hw->phy.type == e1000_phy_82577)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3833
		e1e_rphy(hw, HV_COLC_UPPER, &phy_data);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3834
		if (!e1e_rphy(hw, HV_COLC_LOWER, &phy_data))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3835
			hw->mac.collision_delta = phy_data;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3836
	} else {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3837
		hw->mac.collision_delta = er32(COLC);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3838
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3839
	adapter->stats.colc += hw->mac.collision_delta;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3840
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3841
	adapter->stats.algnerrc += er32(ALGNERRC);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3842
	adapter->stats.rxerrc += er32(RXERRC);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3843
	if ((hw->phy.type == e1000_phy_82578) ||
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3844
	    (hw->phy.type == e1000_phy_82577)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3845
		e1e_rphy(hw, HV_TNCRS_UPPER, &phy_data);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3846
		if (!e1e_rphy(hw, HV_TNCRS_LOWER, &phy_data))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3847
			adapter->stats.tncrs += phy_data;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3848
	} else {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3849
		if ((hw->mac.type != e1000_82574) &&
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3850
		    (hw->mac.type != e1000_82583))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3851
			adapter->stats.tncrs += er32(TNCRS);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3852
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3853
	adapter->stats.cexterr += er32(CEXTERR);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3854
	adapter->stats.tsctc += er32(TSCTC);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3855
	adapter->stats.tsctfc += er32(TSCTFC);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3856
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3857
	/* Fill out the OS statistics structure */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3858
	netdev->stats.multicast = adapter->stats.mprc;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3859
	netdev->stats.collisions = adapter->stats.colc;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3860
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3861
	/* Rx Errors */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3862
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3863
	/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3864
	 * RLEC on some newer hardware can be incorrect so build
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3865
	 * our own version based on RUC and ROC
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3866
	 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3867
	netdev->stats.rx_errors = adapter->stats.rxerrc +
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3868
		adapter->stats.crcerrs + adapter->stats.algnerrc +
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3869
		adapter->stats.ruc + adapter->stats.roc +
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3870
		adapter->stats.cexterr;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3871
	netdev->stats.rx_length_errors = adapter->stats.ruc +
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3872
					      adapter->stats.roc;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3873
	netdev->stats.rx_crc_errors = adapter->stats.crcerrs;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3874
	netdev->stats.rx_frame_errors = adapter->stats.algnerrc;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3875
	netdev->stats.rx_missed_errors = adapter->stats.mpc;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3876
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3877
	/* Tx Errors */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3878
	netdev->stats.tx_errors = adapter->stats.ecol +
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3879
				       adapter->stats.latecol;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3880
	netdev->stats.tx_aborted_errors = adapter->stats.ecol;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3881
	netdev->stats.tx_window_errors = adapter->stats.latecol;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3882
	netdev->stats.tx_carrier_errors = adapter->stats.tncrs;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3883
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3884
	/* Tx Dropped needs to be maintained elsewhere */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3885
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3886
	/* Management Stats */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3887
	adapter->stats.mgptc += er32(MGTPTC);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3888
	adapter->stats.mgprc += er32(MGTPRC);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3889
	adapter->stats.mgpdc += er32(MGTPDC);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3890
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3891
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3892
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3893
 * e1000_phy_read_status - Update the PHY register status snapshot
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3894
 * @adapter: board private structure
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3895
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3896
static void e1000_phy_read_status(struct e1000_adapter *adapter)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3897
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3898
	struct e1000_hw *hw = &adapter->hw;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3899
	struct e1000_phy_regs *phy = &adapter->phy_regs;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3900
	int ret_val;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3901
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3902
	if ((er32(STATUS) & E1000_STATUS_LU) &&
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3903
	    (adapter->hw.phy.media_type == e1000_media_type_copper)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3904
		ret_val  = e1e_rphy(hw, PHY_CONTROL, &phy->bmcr);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3905
		ret_val |= e1e_rphy(hw, PHY_STATUS, &phy->bmsr);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3906
		ret_val |= e1e_rphy(hw, PHY_AUTONEG_ADV, &phy->advertise);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3907
		ret_val |= e1e_rphy(hw, PHY_LP_ABILITY, &phy->lpa);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3908
		ret_val |= e1e_rphy(hw, PHY_AUTONEG_EXP, &phy->expansion);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3909
		ret_val |= e1e_rphy(hw, PHY_1000T_CTRL, &phy->ctrl1000);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3910
		ret_val |= e1e_rphy(hw, PHY_1000T_STATUS, &phy->stat1000);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3911
		ret_val |= e1e_rphy(hw, PHY_EXT_STATUS, &phy->estatus);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3912
		if (ret_val)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3913
			e_warn("Error reading PHY register\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3914
	} else {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3915
		/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3916
		 * Do not read PHY registers if link is not up
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3917
		 * Set values to typical power-on defaults
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3918
		 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3919
		phy->bmcr = (BMCR_SPEED1000 | BMCR_ANENABLE | BMCR_FULLDPLX);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3920
		phy->bmsr = (BMSR_100FULL | BMSR_100HALF | BMSR_10FULL |
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3921
			     BMSR_10HALF | BMSR_ESTATEN | BMSR_ANEGCAPABLE |
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3922
			     BMSR_ERCAP);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3923
		phy->advertise = (ADVERTISE_PAUSE_ASYM | ADVERTISE_PAUSE_CAP |
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3924
				  ADVERTISE_ALL | ADVERTISE_CSMA);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3925
		phy->lpa = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3926
		phy->expansion = EXPANSION_ENABLENPAGE;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3927
		phy->ctrl1000 = ADVERTISE_1000FULL;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3928
		phy->stat1000 = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3929
		phy->estatus = (ESTATUS_1000_TFULL | ESTATUS_1000_THALF);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3930
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3931
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3932
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3933
static void e1000_print_link_info(struct e1000_adapter *adapter)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3934
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3935
	struct e1000_hw *hw = &adapter->hw;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3936
	u32 ctrl = er32(CTRL);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3937
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3938
	/* Link status message must follow this format for user tools */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3939
	printk(KERN_INFO "e1000e: %s NIC Link is Up %d Mbps %s, "
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3940
	       "Flow Control: %s\n",
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3941
	       adapter->netdev->name,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3942
	       adapter->link_speed,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3943
	       (adapter->link_duplex == FULL_DUPLEX) ?
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3944
	                        "Full Duplex" : "Half Duplex",
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3945
	       ((ctrl & E1000_CTRL_TFCE) && (ctrl & E1000_CTRL_RFCE)) ?
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3946
	                        "RX/TX" :
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3947
	       ((ctrl & E1000_CTRL_RFCE) ? "RX" :
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3948
	       ((ctrl & E1000_CTRL_TFCE) ? "TX" : "None" )));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3949
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3950
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3951
bool e1000e_has_link(struct e1000_adapter *adapter)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3952
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3953
	struct e1000_hw *hw = &adapter->hw;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3954
	bool link_active = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3955
	s32 ret_val = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3956
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3957
	/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3958
	 * get_link_status is set on LSC (link status) interrupt or
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3959
	 * Rx sequence error interrupt.  get_link_status will stay
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3960
	 * false until the check_for_link establishes link
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3961
	 * for copper adapters ONLY
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3962
	 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3963
	switch (hw->phy.media_type) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3964
	case e1000_media_type_copper:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3965
		if (hw->mac.get_link_status) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3966
			ret_val = hw->mac.ops.check_for_link(hw);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3967
			link_active = !hw->mac.get_link_status;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3968
		} else {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3969
			link_active = 1;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3970
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3971
		break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3972
	case e1000_media_type_fiber:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3973
		ret_val = hw->mac.ops.check_for_link(hw);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3974
		link_active = !!(er32(STATUS) & E1000_STATUS_LU);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3975
		break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3976
	case e1000_media_type_internal_serdes:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3977
		ret_val = hw->mac.ops.check_for_link(hw);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3978
		link_active = adapter->hw.mac.serdes_has_link;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3979
		break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3980
	default:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3981
	case e1000_media_type_unknown:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3982
		break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3983
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3984
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3985
	if ((ret_val == E1000_ERR_PHY) && (hw->phy.type == e1000_phy_igp_3) &&
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3986
	    (er32(CTRL) & E1000_PHY_CTRL_GBE_DISABLE)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3987
		/* See e1000_kmrn_lock_loss_workaround_ich8lan() */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3988
		e_info("Gigabit has been disabled, downgrading speed\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3989
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3990
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3991
	return link_active;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3992
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3993
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3994
static void e1000e_enable_receives(struct e1000_adapter *adapter)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3995
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3996
	/* make sure the receive unit is started */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3997
	if ((adapter->flags & FLAG_RX_NEEDS_RESTART) &&
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3998
	    (adapter->flags & FLAG_RX_RESTART_NOW)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3999
		struct e1000_hw *hw = &adapter->hw;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4000
		u32 rctl = er32(RCTL);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4001
		ew32(RCTL, rctl | E1000_RCTL_EN);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4002
		adapter->flags &= ~FLAG_RX_RESTART_NOW;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4003
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4004
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4005
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4006
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4007
 * e1000_watchdog - Timer Call-back
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4008
 * @data: pointer to adapter cast into an unsigned long
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4009
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4010
static void e1000_watchdog(unsigned long data)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4011
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4012
	struct e1000_adapter *adapter = (struct e1000_adapter *) data;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4013
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4014
	/* Do the rest outside of interrupt context */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4015
	schedule_work(&adapter->watchdog_task);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4016
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4017
	/* TODO: make this use queue_delayed_work() */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4018
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4019
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4020
static void e1000_watchdog_task(struct work_struct *work)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4021
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4022
	struct e1000_adapter *adapter = container_of(work,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4023
					struct e1000_adapter, watchdog_task);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4024
	struct net_device *netdev = adapter->netdev;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4025
	struct e1000_mac_info *mac = &adapter->hw.mac;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4026
	struct e1000_phy_info *phy = &adapter->hw.phy;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4027
	struct e1000_ring *tx_ring = adapter->tx_ring;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4028
	struct e1000_hw *hw = &adapter->hw;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4029
	u32 link, tctl;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4030
	int tx_pending = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4031
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4032
	link = e1000e_has_link(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4033
	if ((adapter->ecdev && (ecdev_get_link(adapter->ecdev)) && link)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4034
            || (!adapter->ecdev && (netif_carrier_ok(netdev)) && link)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4035
		/* Cancel scheduled suspend requests. */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4036
		pm_runtime_resume(netdev->dev.parent);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4037
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4038
		e1000e_enable_receives(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4039
		goto link_up;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4040
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4041
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4042
	if ((e1000e_enable_tx_pkt_filtering(hw)) &&
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4043
	    (adapter->mng_vlan_id != adapter->hw.mng_cookie.vlan_id))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4044
		e1000_update_mng_vlan(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4045
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4046
	if (link) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4047
		if ((adapter->ecdev && !ecdev_get_link(adapter->ecdev)) 
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4048
				|| (!adapter->ecdev && !netif_carrier_ok(netdev))) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4049
			bool txb2b = 1;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4050
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4051
			/* Cancel scheduled suspend requests. */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4052
			pm_runtime_resume(netdev->dev.parent);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4053
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4054
			/* update snapshot of PHY registers on LSC */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4055
			e1000_phy_read_status(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4056
			mac->ops.get_link_up_info(&adapter->hw,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4057
						   &adapter->link_speed,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4058
						   &adapter->link_duplex);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4059
			e1000_print_link_info(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4060
			/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4061
			 * On supported PHYs, check for duplex mismatch only
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4062
			 * if link has autonegotiated at 10/100 half
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4063
			 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4064
			if ((hw->phy.type == e1000_phy_igp_3 ||
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4065
			     hw->phy.type == e1000_phy_bm) &&
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4066
			    (hw->mac.autoneg == true) &&
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4067
			    (adapter->link_speed == SPEED_10 ||
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4068
			     adapter->link_speed == SPEED_100) &&
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4069
			    (adapter->link_duplex == HALF_DUPLEX)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4070
				u16 autoneg_exp;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4071
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4072
				e1e_rphy(hw, PHY_AUTONEG_EXP, &autoneg_exp);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4073
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4074
				if (!(autoneg_exp & NWAY_ER_LP_NWAY_CAPS))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4075
					e_info("Autonegotiated half duplex but"
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4076
					       " link partner cannot autoneg. "
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4077
					       " Try forcing full duplex if "
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4078
					       "link gets many collisions.\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4079
			}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4080
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4081
			/* adjust timeout factor according to speed/duplex */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4082
			adapter->tx_timeout_factor = 1;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4083
			switch (adapter->link_speed) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4084
			case SPEED_10:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4085
				txb2b = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4086
				adapter->tx_timeout_factor = 16;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4087
				break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4088
			case SPEED_100:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4089
				txb2b = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4090
				adapter->tx_timeout_factor = 10;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4091
				break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4092
			}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4093
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4094
			/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4095
			 * workaround: re-program speed mode bit after
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4096
			 * link-up event
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4097
			 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4098
			if ((adapter->flags & FLAG_TARC_SPEED_MODE_BIT) &&
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4099
			    !txb2b) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4100
				u32 tarc0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4101
				tarc0 = er32(TARC(0));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4102
				tarc0 &= ~SPEED_MODE_BIT;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4103
				ew32(TARC(0), tarc0);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4104
			}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4105
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4106
			/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4107
			 * disable TSO for pcie and 10/100 speeds, to avoid
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4108
			 * some hardware issues
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4109
			 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4110
			if (!(adapter->flags & FLAG_TSO_FORCE)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4111
				switch (adapter->link_speed) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4112
				case SPEED_10:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4113
				case SPEED_100:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4114
					e_info("10/100 speed: disabling TSO\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4115
					netdev->features &= ~NETIF_F_TSO;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4116
					netdev->features &= ~NETIF_F_TSO6;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4117
					break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4118
				case SPEED_1000:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4119
					netdev->features |= NETIF_F_TSO;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4120
					netdev->features |= NETIF_F_TSO6;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4121
					break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4122
				default:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4123
					/* oops */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4124
					break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4125
				}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4126
			}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4127
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4128
			/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4129
			 * enable transmits in the hardware, need to do this
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4130
			 * after setting TARC(0)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4131
			 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4132
			tctl = er32(TCTL);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4133
			tctl |= E1000_TCTL_EN;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4134
			ew32(TCTL, tctl);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4135
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4136
                        /*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4137
			 * Perform any post-link-up configuration before
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4138
			 * reporting link up.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4139
			 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4140
			if (phy->ops.cfg_on_link_up)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4141
				phy->ops.cfg_on_link_up(hw);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4142
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4143
			if (adapter->ecdev)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4144
				ecdev_set_link(adapter->ecdev, 1);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4145
			else 
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4146
				netif_carrier_on(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4147
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4148
			if (!adapter->ecdev && !test_bit(__E1000_DOWN, &adapter->state))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4149
				mod_timer(&adapter->phy_info_timer,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4150
					  round_jiffies(jiffies + 2 * HZ));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4151
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4152
	} else {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4153
		if ((adapter->ecdev && ecdev_get_link(adapter->ecdev)) 
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4154
				|| (!adapter->ecdev && netif_carrier_ok(netdev))) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4155
			adapter->link_speed = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4156
			adapter->link_duplex = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4157
			/* Link status message must follow this format */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4158
			printk(KERN_INFO "e1000e: %s NIC Link is Down\n",
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4159
			       adapter->netdev->name);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4160
			if (adapter->ecdev)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4161
				ecdev_set_link(adapter->ecdev, 0);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4162
			else
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4163
				netif_carrier_off(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4164
			if (!adapter->ecdev && !test_bit(__E1000_DOWN, &adapter->state))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4165
				mod_timer(&adapter->phy_info_timer,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4166
					  round_jiffies(jiffies + 2 * HZ));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4167
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4168
			if (adapter->flags & FLAG_RX_NEEDS_RESTART)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4169
				schedule_work(&adapter->reset_task);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4170
			else
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4171
				pm_schedule_suspend(netdev->dev.parent,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4172
							LINK_TIMEOUT);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4173
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4174
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4175
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4176
link_up:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4177
	e1000e_update_stats(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4178
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4179
	mac->tx_packet_delta = adapter->stats.tpt - adapter->tpt_old;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4180
	adapter->tpt_old = adapter->stats.tpt;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4181
	mac->collision_delta = adapter->stats.colc - adapter->colc_old;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4182
	adapter->colc_old = adapter->stats.colc;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4183
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4184
	adapter->gorc = adapter->stats.gorc - adapter->gorc_old;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4185
	adapter->gorc_old = adapter->stats.gorc;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4186
	adapter->gotc = adapter->stats.gotc - adapter->gotc_old;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4187
	adapter->gotc_old = adapter->stats.gotc;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4188
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4189
	e1000e_update_adaptive(&adapter->hw);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4190
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4191
	if ((adapter->ecdev && !ecdev_get_link(adapter->ecdev)) 
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4192
			|| (!adapter->ecdev && !netif_carrier_ok(netdev))) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4193
		tx_pending = (e1000_desc_unused(tx_ring) + 1 <
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4194
			       tx_ring->count);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4195
		if (tx_pending) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4196
			/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4197
			 * We've lost link, so the controller stops DMA,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4198
			 * but we've got queued Tx work that's never going
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4199
			 * to get done, so reset controller to flush Tx.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4200
			 * (Do the reset outside of interrupt context).
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4201
			 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4202
			adapter->tx_timeout_count++;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4203
			schedule_work(&adapter->reset_task);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4204
			/* return immediately since reset is imminent */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4205
			return;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4206
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4207
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4208
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4209
	/* Simple mode for Interrupt Throttle Rate (ITR) */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4210
	if (adapter->itr_setting == 4) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4211
		/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4212
		 * Symmetric Tx/Rx gets a reduced ITR=2000;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4213
		 * Total asymmetrical Tx or Rx gets ITR=8000;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4214
		 * everyone else is between 2000-8000.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4215
		 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4216
		u32 goc = (adapter->gotc + adapter->gorc) / 10000;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4217
		u32 dif = (adapter->gotc > adapter->gorc ?
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4218
			    adapter->gotc - adapter->gorc :
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4219
			    adapter->gorc - adapter->gotc) / 10000;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4220
		u32 itr = goc > 0 ? (dif * 6000 / goc + 2000) : 8000;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4221
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4222
		ew32(ITR, 1000000000 / (itr * 256));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4223
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4224
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4225
	/* Cause software interrupt to ensure Rx ring is cleaned */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4226
	if (adapter->msix_entries)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4227
		ew32(ICS, adapter->rx_ring->ims_val);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4228
	else
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4229
		ew32(ICS, E1000_ICS_RXDMT0);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4230
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4231
	/* Force detection of hung controller every watchdog period */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4232
	adapter->detect_tx_hung = 1;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4233
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4234
	/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4235
	 * With 82571 controllers, LAA may be overwritten due to controller
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4236
	 * reset from the other port. Set the appropriate LAA in RAR[0]
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4237
	 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4238
	if (e1000e_get_laa_state_82571(hw))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4239
		e1000e_rar_set(hw, adapter->hw.mac.addr, 0);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4240
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4241
	/* Reset the timer */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4242
	if (!adapter->ecdev && !test_bit(__E1000_DOWN, &adapter->state))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4243
		mod_timer(&adapter->watchdog_timer,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4244
			  round_jiffies(jiffies + 2 * HZ));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4245
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4246
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4247
#define E1000_TX_FLAGS_CSUM		0x00000001
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4248
#define E1000_TX_FLAGS_VLAN		0x00000002
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4249
#define E1000_TX_FLAGS_TSO		0x00000004
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4250
#define E1000_TX_FLAGS_IPV4		0x00000008
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4251
#define E1000_TX_FLAGS_VLAN_MASK	0xffff0000
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4252
#define E1000_TX_FLAGS_VLAN_SHIFT	16
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4253
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4254
static int e1000_tso(struct e1000_adapter *adapter,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4255
		     struct sk_buff *skb)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4256
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4257
	struct e1000_ring *tx_ring = adapter->tx_ring;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4258
	struct e1000_context_desc *context_desc;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4259
	struct e1000_buffer *buffer_info;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4260
	unsigned int i;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4261
	u32 cmd_length = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4262
	u16 ipcse = 0, tucse, mss;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4263
	u8 ipcss, ipcso, tucss, tucso, hdr_len;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4264
	int err;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4265
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4266
	if (!skb_is_gso(skb))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4267
		return 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4268
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4269
	if (skb_header_cloned(skb)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4270
		err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4271
		if (err)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4272
			return err;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4273
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4274
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4275
	hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4276
	mss = skb_shinfo(skb)->gso_size;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4277
	if (skb->protocol == htons(ETH_P_IP)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4278
		struct iphdr *iph = ip_hdr(skb);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4279
		iph->tot_len = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4280
		iph->check = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4281
		tcp_hdr(skb)->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4282
		                                         0, IPPROTO_TCP, 0);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4283
		cmd_length = E1000_TXD_CMD_IP;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4284
		ipcse = skb_transport_offset(skb) - 1;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4285
	} else if (skb_is_gso_v6(skb)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4286
		ipv6_hdr(skb)->payload_len = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4287
		tcp_hdr(skb)->check = ~csum_ipv6_magic(&ipv6_hdr(skb)->saddr,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4288
		                                       &ipv6_hdr(skb)->daddr,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4289
		                                       0, IPPROTO_TCP, 0);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4290
		ipcse = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4291
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4292
	ipcss = skb_network_offset(skb);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4293
	ipcso = (void *)&(ip_hdr(skb)->check) - (void *)skb->data;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4294
	tucss = skb_transport_offset(skb);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4295
	tucso = (void *)&(tcp_hdr(skb)->check) - (void *)skb->data;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4296
	tucse = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4297
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4298
	cmd_length |= (E1000_TXD_CMD_DEXT | E1000_TXD_CMD_TSE |
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4299
	               E1000_TXD_CMD_TCP | (skb->len - (hdr_len)));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4300
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4301
	i = tx_ring->next_to_use;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4302
	context_desc = E1000_CONTEXT_DESC(*tx_ring, i);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4303
	buffer_info = &tx_ring->buffer_info[i];
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4304
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4305
	context_desc->lower_setup.ip_fields.ipcss  = ipcss;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4306
	context_desc->lower_setup.ip_fields.ipcso  = ipcso;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4307
	context_desc->lower_setup.ip_fields.ipcse  = cpu_to_le16(ipcse);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4308
	context_desc->upper_setup.tcp_fields.tucss = tucss;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4309
	context_desc->upper_setup.tcp_fields.tucso = tucso;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4310
	context_desc->upper_setup.tcp_fields.tucse = cpu_to_le16(tucse);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4311
	context_desc->tcp_seg_setup.fields.mss     = cpu_to_le16(mss);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4312
	context_desc->tcp_seg_setup.fields.hdr_len = hdr_len;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4313
	context_desc->cmd_and_length = cpu_to_le32(cmd_length);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4314
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4315
	buffer_info->time_stamp = jiffies;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4316
	buffer_info->next_to_watch = i;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4317
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4318
	i++;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4319
	if (i == tx_ring->count)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4320
		i = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4321
	tx_ring->next_to_use = i;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4322
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4323
	return 1;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4324
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4325
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4326
static bool e1000_tx_csum(struct e1000_adapter *adapter, struct sk_buff *skb)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4327
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4328
	struct e1000_ring *tx_ring = adapter->tx_ring;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4329
	struct e1000_context_desc *context_desc;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4330
	struct e1000_buffer *buffer_info;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4331
	unsigned int i;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4332
	u8 css;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4333
	u32 cmd_len = E1000_TXD_CMD_DEXT;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4334
	__be16 protocol;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4335
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4336
	if (skb->ip_summed != CHECKSUM_PARTIAL)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4337
		return 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4338
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4339
	if (skb->protocol == cpu_to_be16(ETH_P_8021Q))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4340
		protocol = vlan_eth_hdr(skb)->h_vlan_encapsulated_proto;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4341
	else
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4342
		protocol = skb->protocol;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4343
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4344
	switch (protocol) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4345
	case cpu_to_be16(ETH_P_IP):
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4346
		if (ip_hdr(skb)->protocol == IPPROTO_TCP)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4347
			cmd_len |= E1000_TXD_CMD_TCP;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4348
		break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4349
	case cpu_to_be16(ETH_P_IPV6):
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4350
		/* XXX not handling all IPV6 headers */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4351
		if (ipv6_hdr(skb)->nexthdr == IPPROTO_TCP)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4352
			cmd_len |= E1000_TXD_CMD_TCP;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4353
		break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4354
	default:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4355
		if (unlikely(net_ratelimit()))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4356
			e_warn("checksum_partial proto=%x!\n",
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4357
			       be16_to_cpu(protocol));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4358
		break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4359
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4360
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4361
	css = skb_transport_offset(skb);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4362
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4363
	i = tx_ring->next_to_use;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4364
	buffer_info = &tx_ring->buffer_info[i];
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4365
	context_desc = E1000_CONTEXT_DESC(*tx_ring, i);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4366
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4367
	context_desc->lower_setup.ip_config = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4368
	context_desc->upper_setup.tcp_fields.tucss = css;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4369
	context_desc->upper_setup.tcp_fields.tucso =
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4370
				css + skb->csum_offset;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4371
	context_desc->upper_setup.tcp_fields.tucse = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4372
	context_desc->tcp_seg_setup.data = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4373
	context_desc->cmd_and_length = cpu_to_le32(cmd_len);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4374
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4375
	buffer_info->time_stamp = jiffies;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4376
	buffer_info->next_to_watch = i;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4377
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4378
	i++;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4379
	if (i == tx_ring->count)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4380
		i = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4381
	tx_ring->next_to_use = i;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4382
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4383
	return 1;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4384
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4385
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4386
#define E1000_MAX_PER_TXD	8192
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4387
#define E1000_MAX_TXD_PWR	12
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4388
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4389
static int e1000_tx_map(struct e1000_adapter *adapter,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4390
			struct sk_buff *skb, unsigned int first,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4391
			unsigned int max_per_txd, unsigned int nr_frags,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4392
			unsigned int mss)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4393
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4394
	struct e1000_ring *tx_ring = adapter->tx_ring;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4395
	struct pci_dev *pdev = adapter->pdev;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4396
	struct e1000_buffer *buffer_info;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4397
	unsigned int len = skb_headlen(skb);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4398
	unsigned int offset = 0, size, count = 0, i;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4399
	unsigned int f, bytecount, segs;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4400
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4401
	i = tx_ring->next_to_use;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4402
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4403
	while (len) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4404
		buffer_info = &tx_ring->buffer_info[i];
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4405
		size = min(len, max_per_txd);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4406
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4407
		buffer_info->length = size;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4408
		buffer_info->time_stamp = jiffies;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4409
		buffer_info->next_to_watch = i;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4410
		buffer_info->dma = dma_map_single(&pdev->dev,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4411
						  skb->data + offset,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4412
						  size,	DMA_TO_DEVICE);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4413
		buffer_info->mapped_as_page = false;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4414
		if (dma_mapping_error(&pdev->dev, buffer_info->dma))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4415
			goto dma_error;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4416
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4417
		len -= size;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4418
		offset += size;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4419
		count++;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4420
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4421
		if (len) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4422
			i++;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4423
			if (i == tx_ring->count)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4424
				i = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4425
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4426
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4427
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4428
	for (f = 0; f < nr_frags; f++) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4429
		struct skb_frag_struct *frag;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4430
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4431
		frag = &skb_shinfo(skb)->frags[f];
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4432
		len = frag->size;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4433
		offset = frag->page_offset;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4434
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4435
		while (len) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4436
			i++;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4437
			if (i == tx_ring->count)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4438
				i = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4439
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4440
			buffer_info = &tx_ring->buffer_info[i];
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4441
			size = min(len, max_per_txd);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4442
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4443
			buffer_info->length = size;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4444
			buffer_info->time_stamp = jiffies;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4445
			buffer_info->next_to_watch = i;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4446
			buffer_info->dma = dma_map_page(&pdev->dev, frag->page,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4447
							offset, size,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4448
							DMA_TO_DEVICE);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4449
			buffer_info->mapped_as_page = true;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4450
			if (dma_mapping_error(&pdev->dev, buffer_info->dma))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4451
				goto dma_error;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4452
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4453
			len -= size;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4454
			offset += size;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4455
			count++;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4456
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4457
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4458
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4459
	segs = skb_shinfo(skb)->gso_segs ?: 1;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4460
	/* multiply data chunks by size of headers */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4461
	bytecount = ((segs - 1) * skb_headlen(skb)) + skb->len;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4462
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4463
	tx_ring->buffer_info[i].skb = skb;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4464
	tx_ring->buffer_info[i].segs = segs;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4465
	tx_ring->buffer_info[i].bytecount = bytecount;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4466
	tx_ring->buffer_info[first].next_to_watch = i;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4467
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4468
	return count;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4469
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4470
dma_error:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4471
	dev_err(&pdev->dev, "TX DMA map failed\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4472
	buffer_info->dma = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4473
	if (count)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4474
		count--;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4475
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4476
	while (count--) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4477
		if (i==0)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4478
			i += tx_ring->count;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4479
		i--;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4480
		buffer_info = &tx_ring->buffer_info[i];
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4481
		e1000_put_txbuf(adapter, buffer_info);;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4482
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4483
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4484
	return 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4485
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4486
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4487
static void e1000_tx_queue(struct e1000_adapter *adapter,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4488
			   int tx_flags, int count)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4489
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4490
	struct e1000_ring *tx_ring = adapter->tx_ring;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4491
	struct e1000_tx_desc *tx_desc = NULL;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4492
	struct e1000_buffer *buffer_info;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4493
	u32 txd_upper = 0, txd_lower = E1000_TXD_CMD_IFCS;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4494
	unsigned int i;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4495
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4496
	if (tx_flags & E1000_TX_FLAGS_TSO) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4497
		txd_lower |= E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D |
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4498
			     E1000_TXD_CMD_TSE;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4499
		txd_upper |= E1000_TXD_POPTS_TXSM << 8;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4500
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4501
		if (tx_flags & E1000_TX_FLAGS_IPV4)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4502
			txd_upper |= E1000_TXD_POPTS_IXSM << 8;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4503
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4504
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4505
	if (tx_flags & E1000_TX_FLAGS_CSUM) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4506
		txd_lower |= E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4507
		txd_upper |= E1000_TXD_POPTS_TXSM << 8;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4508
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4509
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4510
	if (tx_flags & E1000_TX_FLAGS_VLAN) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4511
		txd_lower |= E1000_TXD_CMD_VLE;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4512
		txd_upper |= (tx_flags & E1000_TX_FLAGS_VLAN_MASK);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4513
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4514
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4515
	i = tx_ring->next_to_use;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4516
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4517
	while (count--) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4518
		buffer_info = &tx_ring->buffer_info[i];
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4519
		tx_desc = E1000_TX_DESC(*tx_ring, i);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4520
		tx_desc->buffer_addr = cpu_to_le64(buffer_info->dma);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4521
		tx_desc->lower.data =
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4522
			cpu_to_le32(txd_lower | buffer_info->length);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4523
		tx_desc->upper.data = cpu_to_le32(txd_upper);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4524
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4525
		i++;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4526
		if (i == tx_ring->count)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4527
			i = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4528
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4529
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4530
	tx_desc->lower.data |= cpu_to_le32(adapter->txd_cmd);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4531
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4532
	/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4533
	 * Force memory writes to complete before letting h/w
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4534
	 * know there are new descriptors to fetch.  (Only
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4535
	 * applicable for weak-ordered memory model archs,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4536
	 * such as IA-64).
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4537
	 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4538
	wmb();
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4539
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4540
	tx_ring->next_to_use = i;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4541
	writel(i, adapter->hw.hw_addr + tx_ring->tail);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4542
	/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4543
	 * we need this if more than one processor can write to our tail
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4544
	 * at a time, it synchronizes IO on IA64/Altix systems
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4545
	 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4546
	mmiowb();
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4547
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4548
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4549
#define MINIMUM_DHCP_PACKET_SIZE 282
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4550
static int e1000_transfer_dhcp_info(struct e1000_adapter *adapter,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4551
				    struct sk_buff *skb)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4552
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4553
	struct e1000_hw *hw =  &adapter->hw;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4554
	u16 length, offset;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4555
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4556
	if (vlan_tx_tag_present(skb)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4557
		if (!((vlan_tx_tag_get(skb) == adapter->hw.mng_cookie.vlan_id) &&
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4558
		    (adapter->hw.mng_cookie.status &
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4559
			E1000_MNG_DHCP_COOKIE_STATUS_VLAN)))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4560
			return 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4561
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4562
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4563
	if (skb->len <= MINIMUM_DHCP_PACKET_SIZE)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4564
		return 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4565
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4566
	if (((struct ethhdr *) skb->data)->h_proto != htons(ETH_P_IP))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4567
		return 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4568
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4569
	{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4570
		const struct iphdr *ip = (struct iphdr *)((u8 *)skb->data+14);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4571
		struct udphdr *udp;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4572
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4573
		if (ip->protocol != IPPROTO_UDP)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4574
			return 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4575
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4576
		udp = (struct udphdr *)((u8 *)ip + (ip->ihl << 2));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4577
		if (ntohs(udp->dest) != 67)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4578
			return 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4579
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4580
		offset = (u8 *)udp + 8 - skb->data;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4581
		length = skb->len - offset;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4582
		return e1000e_mng_write_dhcp_info(hw, (u8 *)udp + 8, length);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4583
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4584
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4585
	return 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4586
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4587
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4588
static int __e1000_maybe_stop_tx(struct net_device *netdev, int size)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4589
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4590
	struct e1000_adapter *adapter = netdev_priv(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4591
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4592
	netif_stop_queue(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4593
	/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4594
	 * Herbert's original patch had:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4595
	 *  smp_mb__after_netif_stop_queue();
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4596
	 * but since that doesn't exist yet, just open code it.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4597
	 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4598
	smp_mb();
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4599
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4600
	/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4601
	 * We need to check again in a case another CPU has just
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4602
	 * made room available.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4603
	 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4604
	if (e1000_desc_unused(adapter->tx_ring) < size)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4605
		return -EBUSY;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4606
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4607
	/* A reprieve! */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4608
	netif_start_queue(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4609
	++adapter->restart_queue;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4610
	return 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4611
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4612
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4613
static int e1000_maybe_stop_tx(struct net_device *netdev, int size)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4614
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4615
	struct e1000_adapter *adapter = netdev_priv(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4616
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4617
	if (e1000_desc_unused(adapter->tx_ring) >= size)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4618
		return 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4619
	return __e1000_maybe_stop_tx(netdev, size);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4620
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4621
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4622
#define TXD_USE_COUNT(S, X) (((S) >> (X)) + 1 )
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4623
static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4624
				    struct net_device *netdev)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4625
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4626
	struct e1000_adapter *adapter = netdev_priv(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4627
	struct e1000_ring *tx_ring = adapter->tx_ring;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4628
	unsigned int first;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4629
	unsigned int max_per_txd = E1000_MAX_PER_TXD;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4630
	unsigned int max_txd_pwr = E1000_MAX_TXD_PWR;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4631
	unsigned int tx_flags = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4632
	unsigned int len = skb_headlen(skb);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4633
	unsigned int nr_frags;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4634
	unsigned int mss;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4635
	int count = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4636
	int tso;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4637
	unsigned int f;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4638
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4639
	if (test_bit(__E1000_DOWN, &adapter->state)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4640
		if (!adapter->ecdev)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4641
			dev_kfree_skb_any(skb);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4642
		return NETDEV_TX_OK;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4643
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4644
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4645
	if (skb->len <= 0) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4646
		if (!adapter->ecdev)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4647
			dev_kfree_skb_any(skb);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4648
		return NETDEV_TX_OK;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4649
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4650
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4651
	mss = skb_shinfo(skb)->gso_size;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4652
	/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4653
	 * The controller does a simple calculation to
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4654
	 * make sure there is enough room in the FIFO before
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4655
	 * initiating the DMA for each buffer.  The calc is:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4656
	 * 4 = ceil(buffer len/mss).  To make sure we don't
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4657
	 * overrun the FIFO, adjust the max buffer len if mss
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4658
	 * drops.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4659
	 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4660
	if (mss) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4661
		u8 hdr_len;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4662
		max_per_txd = min(mss << 2, max_per_txd);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4663
		max_txd_pwr = fls(max_per_txd) - 1;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4664
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4665
		/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4666
		 * TSO Workaround for 82571/2/3 Controllers -- if skb->data
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4667
		 * points to just header, pull a few bytes of payload from
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4668
		 * frags into skb->data
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4669
		 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4670
		hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4671
		/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4672
		 * we do this workaround for ES2LAN, but it is un-necessary,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4673
		 * avoiding it could save a lot of cycles
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4674
		 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4675
		if (skb->data_len && (hdr_len == len)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4676
			unsigned int pull_size;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4677
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4678
			pull_size = min((unsigned int)4, skb->data_len);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4679
			if (!__pskb_pull_tail(skb, pull_size)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4680
				e_err("__pskb_pull_tail failed.\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4681
				if (!adapter->ecdev)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4682
					dev_kfree_skb_any(skb);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4683
				return NETDEV_TX_OK;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4684
			}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4685
			len = skb_headlen(skb);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4686
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4687
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4688
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4689
	/* reserve a descriptor for the offload context */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4690
	if ((mss) || (skb->ip_summed == CHECKSUM_PARTIAL))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4691
		count++;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4692
	count++;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4693
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4694
	count += TXD_USE_COUNT(len, max_txd_pwr);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4695
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4696
	nr_frags = skb_shinfo(skb)->nr_frags;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4697
	for (f = 0; f < nr_frags; f++)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4698
		count += TXD_USE_COUNT(skb_shinfo(skb)->frags[f].size,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4699
				       max_txd_pwr);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4700
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4701
	if (adapter->hw.mac.tx_pkt_filtering)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4702
		e1000_transfer_dhcp_info(adapter, skb);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4703
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4704
	/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4705
	 * need: count + 2 desc gap to keep tail from touching
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4706
	 * head, otherwise try next time
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4707
	 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4708
	if (!adapter->ecdev && e1000_maybe_stop_tx(netdev, count + 2))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4709
		return NETDEV_TX_BUSY;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4710
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4711
	if (adapter->vlgrp && vlan_tx_tag_present(skb)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4712
		tx_flags |= E1000_TX_FLAGS_VLAN;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4713
		tx_flags |= (vlan_tx_tag_get(skb) << E1000_TX_FLAGS_VLAN_SHIFT);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4714
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4715
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4716
	first = tx_ring->next_to_use;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4717
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4718
	tso = e1000_tso(adapter, skb);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4719
	if (tso < 0) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4720
		if (!adapter->ecdev)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4721
			dev_kfree_skb_any(skb);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4722
		return NETDEV_TX_OK;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4723
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4724
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4725
	if (tso)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4726
		tx_flags |= E1000_TX_FLAGS_TSO;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4727
	else if (e1000_tx_csum(adapter, skb))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4728
		tx_flags |= E1000_TX_FLAGS_CSUM;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4729
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4730
	/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4731
	 * Old method was to assume IPv4 packet by default if TSO was enabled.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4732
	 * 82571 hardware supports TSO capabilities for IPv6 as well...
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4733
	 * no longer assume, we must.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4734
	 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4735
	if (skb->protocol == htons(ETH_P_IP))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4736
		tx_flags |= E1000_TX_FLAGS_IPV4;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4737
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4738
	/* if count is 0 then mapping error has occured */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4739
	count = e1000_tx_map(adapter, skb, first, max_per_txd, nr_frags, mss);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4740
	if (count) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4741
		e1000_tx_queue(adapter, tx_flags, count);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4742
		/* Make sure there is space in the ring for the next send. */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4743
		if (!adapter->ecdev)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4744
			e1000_maybe_stop_tx(netdev, MAX_SKB_FRAGS + 2);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4745
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4746
	} else {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4747
		if (!adapter->ecdev)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4748
			dev_kfree_skb_any(skb);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4749
		tx_ring->buffer_info[first].time_stamp = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4750
		tx_ring->next_to_use = first;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4751
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4752
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4753
	return NETDEV_TX_OK;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4754
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4755
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4756
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4757
 * e1000_tx_timeout - Respond to a Tx Hang
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4758
 * @netdev: network interface device structure
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4759
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4760
static void e1000_tx_timeout(struct net_device *netdev)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4761
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4762
	struct e1000_adapter *adapter = netdev_priv(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4763
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4764
	/* Do the reset outside of interrupt context */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4765
	adapter->tx_timeout_count++;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4766
	schedule_work(&adapter->reset_task);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4767
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4768
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4769
static void e1000_reset_task(struct work_struct *work)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4770
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4771
	struct e1000_adapter *adapter;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4772
	adapter = container_of(work, struct e1000_adapter, reset_task);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4773
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4774
	e1000e_dump(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4775
	e_err("Reset adapter\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4776
	e1000e_reinit_locked(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4777
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4778
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4779
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4780
 * e1000_get_stats - Get System Network Statistics
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4781
 * @netdev: network interface device structure
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4782
 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4783
 * Returns the address of the device statistics structure.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4784
 * The statistics are actually updated from the timer callback.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4785
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4786
static struct net_device_stats *e1000_get_stats(struct net_device *netdev)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4787
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4788
	/* only return the current stats */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4789
	return &netdev->stats;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4790
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4791
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4792
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4793
 * e1000_change_mtu - Change the Maximum Transfer Unit
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4794
 * @netdev: network interface device structure
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4795
 * @new_mtu: new value for maximum frame size
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4796
 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4797
 * Returns 0 on success, negative on failure
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4798
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4799
static int e1000_change_mtu(struct net_device *netdev, int new_mtu)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4800
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4801
	struct e1000_adapter *adapter = netdev_priv(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4802
	int max_frame = new_mtu + ETH_HLEN + ETH_FCS_LEN;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4803
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4804
	if (adapter->ecdev)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4805
		return -EBUSY;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4806
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4807
	/* Jumbo frame support */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4808
	if ((max_frame > ETH_FRAME_LEN + ETH_FCS_LEN) &&
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4809
	    !(adapter->flags & FLAG_HAS_JUMBO_FRAMES)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4810
		e_err("Jumbo Frames not supported.\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4811
		return -EINVAL;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4812
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4813
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4814
	/* Supported frame sizes */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4815
	if ((new_mtu < ETH_ZLEN + ETH_FCS_LEN + VLAN_HLEN) ||
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4816
	    (max_frame > adapter->max_hw_frame_size)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4817
		e_err("Unsupported MTU setting\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4818
		return -EINVAL;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4819
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4820
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4821
	/* 82573 Errata 17 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4822
	if (((adapter->hw.mac.type == e1000_82573) ||
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4823
	     (adapter->hw.mac.type == e1000_82574)) &&
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4824
	    (max_frame > ETH_FRAME_LEN + ETH_FCS_LEN)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4825
		adapter->flags2 |= FLAG2_DISABLE_ASPM_L1;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4826
		e1000e_disable_aspm(adapter->pdev, PCIE_LINK_STATE_L1);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4827
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4828
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4829
	while (test_and_set_bit(__E1000_RESETTING, &adapter->state))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4830
		msleep(1);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4831
	/* e1000e_down -> e1000e_reset dependent on max_frame_size & mtu */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4832
	adapter->max_frame_size = max_frame;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4833
	e_info("changing MTU from %d to %d\n", netdev->mtu, new_mtu);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4834
	netdev->mtu = new_mtu;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4835
	if (netif_running(netdev))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4836
		e1000e_down(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4837
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4838
	/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4839
	 * NOTE: netdev_alloc_skb reserves 16 bytes, and typically NET_IP_ALIGN
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4840
	 * means we reserve 2 more, this pushes us to allocate from the next
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4841
	 * larger slab size.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4842
	 * i.e. RXBUFFER_2048 --> size-4096 slab
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4843
	 * However with the new *_jumbo_rx* routines, jumbo receives will use
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4844
	 * fragmented skbs
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4845
	 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4846
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4847
	if (max_frame <= 2048)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4848
		adapter->rx_buffer_len = 2048;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4849
	else
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4850
		adapter->rx_buffer_len = 4096;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4851
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4852
	/* adjust allocation if LPE protects us, and we aren't using SBP */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4853
	if ((max_frame == ETH_FRAME_LEN + ETH_FCS_LEN) ||
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4854
	     (max_frame == ETH_FRAME_LEN + VLAN_HLEN + ETH_FCS_LEN))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4855
		adapter->rx_buffer_len = ETH_FRAME_LEN + VLAN_HLEN
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4856
					 + ETH_FCS_LEN;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4857
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4858
	if (netif_running(netdev))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4859
		e1000e_up(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4860
	else
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4861
		e1000e_reset(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4862
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4863
	clear_bit(__E1000_RESETTING, &adapter->state);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4864
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4865
	return 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4866
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4867
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4868
static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4869
			   int cmd)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4870
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4871
	struct e1000_adapter *adapter = netdev_priv(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4872
	struct mii_ioctl_data *data = if_mii(ifr);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4873
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4874
	if (adapter->hw.phy.media_type != e1000_media_type_copper)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4875
		return -EOPNOTSUPP;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4876
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4877
	switch (cmd) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4878
	case SIOCGMIIPHY:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4879
		data->phy_id = adapter->hw.phy.addr;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4880
		break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4881
	case SIOCGMIIREG:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4882
		e1000_phy_read_status(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4883
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4884
		switch (data->reg_num & 0x1F) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4885
		case MII_BMCR:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4886
			data->val_out = adapter->phy_regs.bmcr;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4887
			break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4888
		case MII_BMSR:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4889
			data->val_out = adapter->phy_regs.bmsr;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4890
			break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4891
		case MII_PHYSID1:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4892
			data->val_out = (adapter->hw.phy.id >> 16);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4893
			break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4894
		case MII_PHYSID2:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4895
			data->val_out = (adapter->hw.phy.id & 0xFFFF);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4896
			break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4897
		case MII_ADVERTISE:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4898
			data->val_out = adapter->phy_regs.advertise;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4899
			break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4900
		case MII_LPA:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4901
			data->val_out = adapter->phy_regs.lpa;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4902
			break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4903
		case MII_EXPANSION:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4904
			data->val_out = adapter->phy_regs.expansion;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4905
			break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4906
		case MII_CTRL1000:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4907
			data->val_out = adapter->phy_regs.ctrl1000;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4908
			break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4909
		case MII_STAT1000:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4910
			data->val_out = adapter->phy_regs.stat1000;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4911
			break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4912
		case MII_ESTATUS:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4913
			data->val_out = adapter->phy_regs.estatus;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4914
			break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4915
		default:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4916
			return -EIO;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4917
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4918
		break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4919
	case SIOCSMIIREG:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4920
	default:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4921
		return -EOPNOTSUPP;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4922
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4923
	return 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4924
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4925
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4926
static int e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4927
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4928
	switch (cmd) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4929
	case SIOCGMIIPHY:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4930
	case SIOCGMIIREG:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4931
	case SIOCSMIIREG:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4932
		return e1000_mii_ioctl(netdev, ifr, cmd);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4933
	default:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4934
		return -EOPNOTSUPP;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4935
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4936
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4937
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4938
static int e1000_init_phy_wakeup(struct e1000_adapter *adapter, u32 wufc)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4939
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4940
	struct e1000_hw *hw = &adapter->hw;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4941
	u32 i, mac_reg;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4942
	u16 phy_reg;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4943
	int retval = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4944
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4945
	/* copy MAC RARs to PHY RARs */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4946
	for (i = 0; i < adapter->hw.mac.rar_entry_count; i++) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4947
		mac_reg = er32(RAL(i));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4948
		e1e_wphy(hw, BM_RAR_L(i), (u16)(mac_reg & 0xFFFF));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4949
		e1e_wphy(hw, BM_RAR_M(i), (u16)((mac_reg >> 16) & 0xFFFF));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4950
		mac_reg = er32(RAH(i));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4951
		e1e_wphy(hw, BM_RAR_H(i), (u16)(mac_reg & 0xFFFF));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4952
		e1e_wphy(hw, BM_RAR_CTRL(i), (u16)((mac_reg >> 16) & 0xFFFF));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4953
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4954
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4955
	/* copy MAC MTA to PHY MTA */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4956
	for (i = 0; i < adapter->hw.mac.mta_reg_count; i++) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4957
		mac_reg = E1000_READ_REG_ARRAY(hw, E1000_MTA, i);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4958
		e1e_wphy(hw, BM_MTA(i), (u16)(mac_reg & 0xFFFF));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4959
		e1e_wphy(hw, BM_MTA(i) + 1, (u16)((mac_reg >> 16) & 0xFFFF));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4960
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4961
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4962
	/* configure PHY Rx Control register */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4963
	e1e_rphy(&adapter->hw, BM_RCTL, &phy_reg);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4964
	mac_reg = er32(RCTL);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4965
	if (mac_reg & E1000_RCTL_UPE)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4966
		phy_reg |= BM_RCTL_UPE;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4967
	if (mac_reg & E1000_RCTL_MPE)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4968
		phy_reg |= BM_RCTL_MPE;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4969
	phy_reg &= ~(BM_RCTL_MO_MASK);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4970
	if (mac_reg & E1000_RCTL_MO_3)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4971
		phy_reg |= (((mac_reg & E1000_RCTL_MO_3) >> E1000_RCTL_MO_SHIFT)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4972
				<< BM_RCTL_MO_SHIFT);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4973
	if (mac_reg & E1000_RCTL_BAM)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4974
		phy_reg |= BM_RCTL_BAM;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4975
	if (mac_reg & E1000_RCTL_PMCF)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4976
		phy_reg |= BM_RCTL_PMCF;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4977
	mac_reg = er32(CTRL);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4978
	if (mac_reg & E1000_CTRL_RFCE)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4979
		phy_reg |= BM_RCTL_RFCE;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4980
	e1e_wphy(&adapter->hw, BM_RCTL, phy_reg);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4981
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4982
	/* enable PHY wakeup in MAC register */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4983
	ew32(WUFC, wufc);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4984
	ew32(WUC, E1000_WUC_PHY_WAKE | E1000_WUC_PME_EN);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4985
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4986
	/* configure and enable PHY wakeup in PHY registers */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4987
	e1e_wphy(&adapter->hw, BM_WUFC, wufc);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4988
	e1e_wphy(&adapter->hw, BM_WUC, E1000_WUC_PME_EN);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4989
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4990
	/* activate PHY wakeup */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4991
	retval = hw->phy.ops.acquire(hw);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4992
	if (retval) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4993
		e_err("Could not acquire PHY\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4994
		return retval;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4995
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4996
	e1000e_write_phy_reg_mdic(hw, IGP01E1000_PHY_PAGE_SELECT,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4997
	                         (BM_WUC_ENABLE_PAGE << IGP_PAGE_SHIFT));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4998
	retval = e1000e_read_phy_reg_mdic(hw, BM_WUC_ENABLE_REG, &phy_reg);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4999
	if (retval) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5000
		e_err("Could not read PHY page 769\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5001
		goto out;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5002
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5003
	phy_reg |= BM_WUC_ENABLE_BIT | BM_WUC_HOST_WU_BIT;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5004
	retval = e1000e_write_phy_reg_mdic(hw, BM_WUC_ENABLE_REG, phy_reg);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5005
	if (retval)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5006
		e_err("Could not set PHY Host Wakeup bit\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5007
out:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5008
	hw->phy.ops.release(hw);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5009
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5010
	return retval;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5011
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5012
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5013
static int __e1000_shutdown(struct pci_dev *pdev, bool *enable_wake,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5014
			    bool runtime)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5015
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5016
	struct net_device *netdev = pci_get_drvdata(pdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5017
	struct e1000_adapter *adapter = netdev_priv(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5018
	struct e1000_hw *hw = &adapter->hw;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5019
	u32 ctrl, ctrl_ext, rctl, status;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5020
	/* Runtime suspend should only enable wakeup for link changes */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5021
	u32 wufc = runtime ? E1000_WUFC_LNKC : adapter->wol;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5022
	int retval = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5023
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5024
	netif_device_detach(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5025
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5026
	if (netif_running(netdev)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5027
		WARN_ON(test_bit(__E1000_RESETTING, &adapter->state));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5028
		e1000e_down(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5029
		e1000_free_irq(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5030
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5031
	e1000e_reset_interrupt_capability(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5032
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5033
	retval = pci_save_state(pdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5034
	if (retval)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5035
		return retval;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5036
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5037
	status = er32(STATUS);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5038
	if (status & E1000_STATUS_LU)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5039
		wufc &= ~E1000_WUFC_LNKC;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5040
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5041
	if (wufc) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5042
		e1000_setup_rctl(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5043
		e1000_set_multi(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5044
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5045
		/* turn on all-multi mode if wake on multicast is enabled */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5046
		if (wufc & E1000_WUFC_MC) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5047
			rctl = er32(RCTL);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5048
			rctl |= E1000_RCTL_MPE;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5049
			ew32(RCTL, rctl);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5050
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5051
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5052
		ctrl = er32(CTRL);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5053
		/* advertise wake from D3Cold */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5054
		#define E1000_CTRL_ADVD3WUC 0x00100000
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5055
		/* phy power management enable */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5056
		#define E1000_CTRL_EN_PHY_PWR_MGMT 0x00200000
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5057
		ctrl |= E1000_CTRL_ADVD3WUC;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5058
		if (!(adapter->flags2 & FLAG2_HAS_PHY_WAKEUP))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5059
			ctrl |= E1000_CTRL_EN_PHY_PWR_MGMT;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5060
		ew32(CTRL, ctrl);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5061
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5062
		if (adapter->hw.phy.media_type == e1000_media_type_fiber ||
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5063
		    adapter->hw.phy.media_type ==
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5064
		    e1000_media_type_internal_serdes) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5065
			/* keep the laser running in D3 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5066
			ctrl_ext = er32(CTRL_EXT);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5067
			ctrl_ext |= E1000_CTRL_EXT_SDP3_DATA;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5068
			ew32(CTRL_EXT, ctrl_ext);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5069
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5070
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5071
		if (adapter->flags & FLAG_IS_ICH)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5072
			e1000e_disable_gig_wol_ich8lan(&adapter->hw);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5073
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5074
		/* Allow time for pending master requests to run */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5075
		e1000e_disable_pcie_master(&adapter->hw);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5076
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5077
		if (adapter->flags2 & FLAG2_HAS_PHY_WAKEUP) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5078
			/* enable wakeup by the PHY */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5079
			retval = e1000_init_phy_wakeup(adapter, wufc);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5080
			if (retval)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5081
				return retval;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5082
		} else {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5083
			/* enable wakeup by the MAC */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5084
			ew32(WUFC, wufc);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5085
			ew32(WUC, E1000_WUC_PME_EN);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5086
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5087
	} else {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5088
		ew32(WUC, 0);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5089
		ew32(WUFC, 0);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5090
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5091
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5092
	*enable_wake = !!wufc;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5093
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5094
	/* make sure adapter isn't asleep if manageability is enabled */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5095
	if ((adapter->flags & FLAG_MNG_PT_ENABLED) ||
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5096
	    (hw->mac.ops.check_mng_mode(hw)))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5097
		*enable_wake = true;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5098
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5099
	if (adapter->hw.phy.type == e1000_phy_igp_3)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5100
		e1000e_igp3_phy_powerdown_workaround_ich8lan(&adapter->hw);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5101
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5102
	/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5103
	 * Release control of h/w to f/w.  If f/w is AMT enabled, this
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5104
	 * would have already happened in close and is redundant.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5105
	 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5106
	e1000_release_hw_control(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5107
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5108
	pci_disable_device(pdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5109
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5110
	return 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5111
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5112
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5113
static void e1000_power_off(struct pci_dev *pdev, bool sleep, bool wake)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5114
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5115
	if (sleep && wake) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5116
		pci_prepare_to_sleep(pdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5117
		return;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5118
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5119
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5120
	pci_wake_from_d3(pdev, wake);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5121
	pci_set_power_state(pdev, PCI_D3hot);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5122
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5123
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5124
static void e1000_complete_shutdown(struct pci_dev *pdev, bool sleep,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5125
                                    bool wake)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5126
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5127
	struct net_device *netdev = pci_get_drvdata(pdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5128
	struct e1000_adapter *adapter = netdev_priv(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5129
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5130
	/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5131
	 * The pci-e switch on some quad port adapters will report a
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5132
	 * correctable error when the MAC transitions from D0 to D3.  To
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5133
	 * prevent this we need to mask off the correctable errors on the
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5134
	 * downstream port of the pci-e switch.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5135
	 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5136
	if (adapter->flags & FLAG_IS_QUAD_PORT) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5137
		struct pci_dev *us_dev = pdev->bus->self;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5138
		int pos = pci_find_capability(us_dev, PCI_CAP_ID_EXP);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5139
		u16 devctl;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5140
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5141
		pci_read_config_word(us_dev, pos + PCI_EXP_DEVCTL, &devctl);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5142
		pci_write_config_word(us_dev, pos + PCI_EXP_DEVCTL,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5143
		                      (devctl & ~PCI_EXP_DEVCTL_CERE));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5144
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5145
		e1000_power_off(pdev, sleep, wake);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5146
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5147
		pci_write_config_word(us_dev, pos + PCI_EXP_DEVCTL, devctl);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5148
	} else {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5149
		e1000_power_off(pdev, sleep, wake);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5150
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5151
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5152
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5153
#ifdef CONFIG_PCIEASPM
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5154
static void __e1000e_disable_aspm(struct pci_dev *pdev, u16 state)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5155
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5156
	pci_disable_link_state(pdev, state);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5157
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5158
#else
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5159
static void __e1000e_disable_aspm(struct pci_dev *pdev, u16 state)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5160
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5161
	int pos;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5162
	u16 reg16;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5163
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5164
	/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5165
	 * Both device and parent should have the same ASPM setting.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5166
	 * Disable ASPM in downstream component first and then upstream.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5167
	 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5168
	pos = pci_pcie_cap(pdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5169
	pci_read_config_word(pdev, pos + PCI_EXP_LNKCTL, &reg16);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5170
	reg16 &= ~state;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5171
	pci_write_config_word(pdev, pos + PCI_EXP_LNKCTL, reg16);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5172
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5173
	if (!pdev->bus->self)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5174
		return;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5175
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5176
	pos = pci_pcie_cap(pdev->bus->self);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5177
	pci_read_config_word(pdev->bus->self, pos + PCI_EXP_LNKCTL, &reg16);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5178
	reg16 &= ~state;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5179
	pci_write_config_word(pdev->bus->self, pos + PCI_EXP_LNKCTL, reg16);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5180
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5181
#endif
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5182
void e1000e_disable_aspm(struct pci_dev *pdev, u16 state)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5183
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5184
	dev_info(&pdev->dev, "Disabling ASPM %s %s\n",
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5185
		 (state & PCIE_LINK_STATE_L0S) ? "L0s" : "",
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5186
		 (state & PCIE_LINK_STATE_L1) ? "L1" : "");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5187
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5188
	__e1000e_disable_aspm(pdev, state);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5189
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5190
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5191
#ifdef CONFIG_PM_OPS
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5192
static bool e1000e_pm_ready(struct e1000_adapter *adapter)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5193
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5194
	return !!adapter->tx_ring->buffer_info;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5195
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5196
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5197
static int __e1000_resume(struct pci_dev *pdev)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5198
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5199
	struct net_device *netdev = pci_get_drvdata(pdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5200
	struct e1000_adapter *adapter = netdev_priv(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5201
	struct e1000_hw *hw = &adapter->hw;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5202
	u32 err;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5203
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5204
	if (adapter->ecdev)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5205
		return -EBUSY;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5206
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5207
	pci_set_power_state(pdev, PCI_D0);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5208
	pci_restore_state(pdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5209
	pci_save_state(pdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5210
	if (adapter->flags2 & FLAG2_DISABLE_ASPM_L1)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5211
		e1000e_disable_aspm(pdev, PCIE_LINK_STATE_L1);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5212
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5213
	e1000e_set_interrupt_capability(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5214
	if (netif_running(netdev)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5215
		err = e1000_request_irq(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5216
		if (err)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5217
			return err;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5218
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5219
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5220
	e1000e_power_up_phy(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5221
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5222
	/* report the system wakeup cause from S3/S4 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5223
	if (adapter->flags2 & FLAG2_HAS_PHY_WAKEUP) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5224
		u16 phy_data;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5225
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5226
		e1e_rphy(&adapter->hw, BM_WUS, &phy_data);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5227
		if (phy_data) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5228
			e_info("PHY Wakeup cause - %s\n",
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5229
				phy_data & E1000_WUS_EX ? "Unicast Packet" :
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5230
				phy_data & E1000_WUS_MC ? "Multicast Packet" :
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5231
				phy_data & E1000_WUS_BC ? "Broadcast Packet" :
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5232
				phy_data & E1000_WUS_MAG ? "Magic Packet" :
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5233
				phy_data & E1000_WUS_LNKC ? "Link Status "
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5234
				" Change" : "other");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5235
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5236
		e1e_wphy(&adapter->hw, BM_WUS, ~0);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5237
	} else {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5238
		u32 wus = er32(WUS);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5239
		if (wus) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5240
			e_info("MAC Wakeup cause - %s\n",
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5241
				wus & E1000_WUS_EX ? "Unicast Packet" :
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5242
				wus & E1000_WUS_MC ? "Multicast Packet" :
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5243
				wus & E1000_WUS_BC ? "Broadcast Packet" :
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5244
				wus & E1000_WUS_MAG ? "Magic Packet" :
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5245
				wus & E1000_WUS_LNKC ? "Link Status Change" :
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5246
				"other");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5247
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5248
		ew32(WUS, ~0);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5249
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5250
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5251
	e1000e_reset(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5252
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5253
	e1000_init_manageability_pt(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5254
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5255
	if (netif_running(netdev))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5256
		e1000e_up(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5257
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5258
	netif_device_attach(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5259
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5260
	/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5261
	 * If the controller has AMT, do not set DRV_LOAD until the interface
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5262
	 * is up.  For all other cases, let the f/w know that the h/w is now
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5263
	 * under the control of the driver.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5264
	 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5265
	if (!(adapter->flags & FLAG_HAS_AMT))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5266
		e1000_get_hw_control(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5267
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5268
	return 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5269
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5270
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5271
#ifdef CONFIG_PM_SLEEP
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5272
static int e1000_suspend(struct device *dev)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5273
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5274
	struct pci_dev *pdev = to_pci_dev(dev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5275
	int retval;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5276
	bool wake;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5277
	struct net_device *netdev = pci_get_drvdata(pdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5278
	struct e1000_adapter *adapter = netdev_priv(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5279
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5280
    if (adapter->ecdev) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5281
        return -EBUSY;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5282
    }
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5283
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5284
	retval = __e1000_shutdown(pdev, &wake, false);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5285
	if (!retval)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5286
		e1000_complete_shutdown(pdev, true, wake);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5287
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5288
	return retval;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5289
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5290
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5291
static int e1000_resume(struct device *dev)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5292
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5293
	struct pci_dev *pdev = to_pci_dev(dev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5294
	struct net_device *netdev = pci_get_drvdata(pdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5295
	struct e1000_adapter *adapter = netdev_priv(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5296
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5297
    if (adapter->ecdev) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5298
        return -EBUSY;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5299
    }
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5300
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5301
	if (e1000e_pm_ready(adapter))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5302
		adapter->idle_check = true;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5303
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5304
	return __e1000_resume(pdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5305
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5306
#endif /* CONFIG_PM_SLEEP */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5307
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5308
#ifdef CONFIG_PM_RUNTIME
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5309
static int e1000_runtime_suspend(struct device *dev)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5310
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5311
	struct pci_dev *pdev = to_pci_dev(dev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5312
	struct net_device *netdev = pci_get_drvdata(pdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5313
	struct e1000_adapter *adapter = netdev_priv(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5314
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5315
	if (e1000e_pm_ready(adapter)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5316
		bool wake;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5317
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5318
		__e1000_shutdown(pdev, &wake, true);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5319
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5320
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5321
	return 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5322
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5323
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5324
static int e1000_idle(struct device *dev)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5325
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5326
	struct pci_dev *pdev = to_pci_dev(dev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5327
	struct net_device *netdev = pci_get_drvdata(pdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5328
	struct e1000_adapter *adapter = netdev_priv(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5329
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5330
	if (!e1000e_pm_ready(adapter))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5331
		return 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5332
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5333
	if (adapter->idle_check) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5334
		adapter->idle_check = false;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5335
		if (!e1000e_has_link(adapter))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5336
			pm_schedule_suspend(dev, MSEC_PER_SEC);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5337
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5338
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5339
	return -EBUSY;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5340
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5341
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5342
static int e1000_runtime_resume(struct device *dev)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5343
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5344
	struct pci_dev *pdev = to_pci_dev(dev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5345
	struct net_device *netdev = pci_get_drvdata(pdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5346
	struct e1000_adapter *adapter = netdev_priv(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5347
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5348
	if (!e1000e_pm_ready(adapter))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5349
		return 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5350
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5351
	adapter->idle_check = !dev->power.runtime_auto;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5352
	return __e1000_resume(pdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5353
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5354
#endif /* CONFIG_PM_RUNTIME */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5355
#endif /* CONFIG_PM_OPS */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5356
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5357
static void e1000_shutdown(struct pci_dev *pdev)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5358
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5359
	bool wake = false;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5360
	struct net_device *netdev = pci_get_drvdata(pdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5361
	struct e1000_adapter *adapter = netdev_priv(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5362
	
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5363
	if (adapter->ecdev)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5364
		return;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5365
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5366
	__e1000_shutdown(pdev, &wake, false);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5367
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5368
	if (system_state == SYSTEM_POWER_OFF)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5369
		e1000_complete_shutdown(pdev, false, wake);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5370
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5371
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5372
#ifdef CONFIG_NET_POLL_CONTROLLER
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5373
/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5374
 * Polling 'interrupt' - used by things like netconsole to send skbs
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5375
 * without having to re-enable interrupts. It's not called while
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5376
 * the interrupt routine is executing.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5377
 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5378
static void e1000_netpoll(struct net_device *netdev)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5379
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5380
	struct e1000_adapter *adapter = netdev_priv(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5381
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5382
	disable_irq(adapter->pdev->irq);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5383
	e1000_intr(adapter->pdev->irq, netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5384
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5385
	enable_irq(adapter->pdev->irq);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5386
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5387
#endif
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5388
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5389
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5390
 * e1000_io_error_detected - called when PCI error is detected
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5391
 * @pdev: Pointer to PCI device
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5392
 * @state: The current pci connection state
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5393
 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5394
 * This function is called after a PCI bus error affecting
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5395
 * this device has been detected.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5396
 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5397
static pci_ers_result_t e1000_io_error_detected(struct pci_dev *pdev,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5398
						pci_channel_state_t state)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5399
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5400
	struct net_device *netdev = pci_get_drvdata(pdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5401
	struct e1000_adapter *adapter = netdev_priv(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5402
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5403
	netif_device_detach(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5404
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5405
	if (state == pci_channel_io_perm_failure)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5406
		return PCI_ERS_RESULT_DISCONNECT;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5407
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5408
	if (netif_running(netdev))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5409
		e1000e_down(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5410
	pci_disable_device(pdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5411
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5412
	/* Request a slot slot reset. */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5413
	return PCI_ERS_RESULT_NEED_RESET;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5414
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5415
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5416
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5417
 * e1000_io_slot_reset - called after the pci bus has been reset.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5418
 * @pdev: Pointer to PCI device
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5419
 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5420
 * Restart the card from scratch, as if from a cold-boot. Implementation
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5421
 * resembles the first-half of the e1000_resume routine.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5422
 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5423
static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5424
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5425
	struct net_device *netdev = pci_get_drvdata(pdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5426
	struct e1000_adapter *adapter = netdev_priv(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5427
	struct e1000_hw *hw = &adapter->hw;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5428
	int err;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5429
	pci_ers_result_t result;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5430
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5431
	if (adapter->flags2 & FLAG2_DISABLE_ASPM_L1)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5432
		e1000e_disable_aspm(pdev, PCIE_LINK_STATE_L1);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5433
	err = pci_enable_device_mem(pdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5434
	if (err) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5435
		dev_err(&pdev->dev,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5436
			"Cannot re-enable PCI device after reset.\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5437
		result = PCI_ERS_RESULT_DISCONNECT;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5438
	} else {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5439
		pci_set_master(pdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5440
		pdev->state_saved = true;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5441
		pci_restore_state(pdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5442
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5443
		pci_enable_wake(pdev, PCI_D3hot, 0);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5444
		pci_enable_wake(pdev, PCI_D3cold, 0);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5445
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5446
		e1000e_reset(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5447
		ew32(WUS, ~0);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5448
		result = PCI_ERS_RESULT_RECOVERED;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5449
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5450
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5451
	pci_cleanup_aer_uncorrect_error_status(pdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5452
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5453
	return result;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5454
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5455
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5456
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5457
 * e1000_io_resume - called when traffic can start flowing again.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5458
 * @pdev: Pointer to PCI device
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5459
 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5460
 * This callback is called when the error recovery driver tells us that
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5461
 * its OK to resume normal operation. Implementation resembles the
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5462
 * second-half of the e1000_resume routine.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5463
 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5464
static void e1000_io_resume(struct pci_dev *pdev)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5465
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5466
	struct net_device *netdev = pci_get_drvdata(pdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5467
	struct e1000_adapter *adapter = netdev_priv(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5468
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5469
	e1000_init_manageability_pt(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5470
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5471
	if (netif_running(netdev)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5472
		if (e1000e_up(adapter)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5473
			dev_err(&pdev->dev,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5474
				"can't bring device back up after reset\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5475
			return;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5476
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5477
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5478
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5479
	netif_device_attach(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5480
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5481
	/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5482
	 * If the controller has AMT, do not set DRV_LOAD until the interface
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5483
	 * is up.  For all other cases, let the f/w know that the h/w is now
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5484
	 * under the control of the driver.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5485
	 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5486
	if (!(adapter->flags & FLAG_HAS_AMT))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5487
		e1000_get_hw_control(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5488
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5489
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5490
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5491
static void e1000_print_device_info(struct e1000_adapter *adapter)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5492
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5493
	struct e1000_hw *hw = &adapter->hw;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5494
	struct net_device *netdev = adapter->netdev;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5495
	u32 pba_num;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5496
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5497
	/* print bus type/speed/width info */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5498
	e_info("(PCI Express:2.5GB/s:%s) %pM\n",
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5499
	       /* bus width */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5500
	       ((hw->bus.width == e1000_bus_width_pcie_x4) ? "Width x4" :
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5501
	        "Width x1"),
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5502
	       /* MAC address */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5503
	       netdev->dev_addr);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5504
	e_info("Intel(R) PRO/%s Network Connection\n",
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5505
	       (hw->phy.type == e1000_phy_ife) ? "10/100" : "1000");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5506
	e1000e_read_pba_num(hw, &pba_num);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5507
	e_info("MAC: %d, PHY: %d, PBA No: %06x-%03x\n",
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5508
	       hw->mac.type, hw->phy.type, (pba_num >> 8), (pba_num & 0xff));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5509
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5510
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5511
static void e1000_eeprom_checks(struct e1000_adapter *adapter)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5512
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5513
	struct e1000_hw *hw = &adapter->hw;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5514
	int ret_val;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5515
	u16 buf = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5516
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5517
	if (hw->mac.type != e1000_82573)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5518
		return;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5519
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5520
	ret_val = e1000_read_nvm(hw, NVM_INIT_CONTROL2_REG, 1, &buf);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5521
	if (!ret_val && (!(le16_to_cpu(buf) & (1 << 0)))) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5522
		/* Deep Smart Power Down (DSPD) */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5523
		dev_warn(&adapter->pdev->dev,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5524
			 "Warning: detected DSPD enabled in EEPROM\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5525
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5526
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5527
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5528
static const struct net_device_ops e1000e_netdev_ops = {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5529
	.ndo_open		= e1000_open,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5530
	.ndo_stop		= e1000_close,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5531
	.ndo_start_xmit		= e1000_xmit_frame,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5532
	.ndo_get_stats		= e1000_get_stats,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5533
	.ndo_set_multicast_list	= e1000_set_multi,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5534
	.ndo_set_mac_address	= e1000_set_mac,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5535
	.ndo_change_mtu		= e1000_change_mtu,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5536
	.ndo_do_ioctl		= e1000_ioctl,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5537
	.ndo_tx_timeout		= e1000_tx_timeout,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5538
	.ndo_validate_addr	= eth_validate_addr,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5539
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5540
	.ndo_vlan_rx_register	= e1000_vlan_rx_register,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5541
	.ndo_vlan_rx_add_vid	= e1000_vlan_rx_add_vid,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5542
	.ndo_vlan_rx_kill_vid	= e1000_vlan_rx_kill_vid,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5543
#ifdef CONFIG_NET_POLL_CONTROLLER
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5544
	.ndo_poll_controller	= e1000_netpoll,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5545
#endif
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5546
};
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5547
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5548
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5549
 * ec_poll - Ethercat poll Routine
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5550
 * @netdev: net device structure
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5551
 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5552
 * This function can never fail.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5553
 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5554
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5555
void ec_poll(struct net_device *netdev)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5556
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5557
	struct e1000_adapter *adapter = netdev_priv(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5558
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5559
	if (jiffies - adapter->ec_watchdog_jiffies >= 2 * HZ) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5560
		e1000_watchdog((unsigned long) adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5561
		adapter->ec_watchdog_jiffies = jiffies;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5562
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5563
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5564
#ifdef CONFIG_PCI_MSI
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5565
	e1000_intr_msi(0,netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5566
#else
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5567
	e1000_intr(0,netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5568
#endif
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5569
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5570
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5571
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5572
 * e1000_probe - Device Initialization Routine
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5573
 * @pdev: PCI device information struct
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5574
 * @ent: entry in e1000_pci_tbl
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5575
 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5576
 * Returns 0 on success, negative on failure
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5577
 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5578
 * e1000_probe initializes an adapter identified by a pci_dev structure.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5579
 * The OS initialization, configuring of the adapter private structure,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5580
 * and a hardware reset occur.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5581
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5582
static int __devinit e1000_probe(struct pci_dev *pdev,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5583
				 const struct pci_device_id *ent)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5584
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5585
	struct net_device *netdev;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5586
	struct e1000_adapter *adapter;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5587
	struct e1000_hw *hw;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5588
	const struct e1000_info *ei = e1000_info_tbl[ent->driver_data];
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5589
	resource_size_t mmio_start, mmio_len;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5590
	resource_size_t flash_start, flash_len;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5591
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5592
	static int cards_found;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5593
	int i, err, pci_using_dac;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5594
	u16 eeprom_data = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5595
	u16 eeprom_apme_mask = E1000_EEPROM_APME;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5596
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5597
	if (ei->flags2 & FLAG2_DISABLE_ASPM_L1)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5598
		e1000e_disable_aspm(pdev, PCIE_LINK_STATE_L1);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5599
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5600
	err = pci_enable_device_mem(pdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5601
	if (err)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5602
		return err;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5603
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5604
	pci_using_dac = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5605
	err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(64));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5606
	if (!err) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5607
		err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5608
		if (!err)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5609
			pci_using_dac = 1;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5610
	} else {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5611
		err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5612
		if (err) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5613
			err = dma_set_coherent_mask(&pdev->dev,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5614
						    DMA_BIT_MASK(32));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5615
			if (err) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5616
				dev_err(&pdev->dev, "No usable DMA "
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5617
					"configuration, aborting\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5618
				goto err_dma;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5619
			}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5620
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5621
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5622
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5623
	err = pci_request_selected_regions_exclusive(pdev,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5624
	                                  pci_select_bars(pdev, IORESOURCE_MEM),
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5625
	                                  e1000e_driver_name);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5626
	if (err)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5627
		goto err_pci_reg;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5628
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5629
	/* AER (Advanced Error Reporting) hooks */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5630
	pci_enable_pcie_error_reporting(pdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5631
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5632
	pci_set_master(pdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5633
	/* PCI config space info */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5634
	err = pci_save_state(pdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5635
	if (err)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5636
		goto err_alloc_etherdev;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5637
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5638
	err = -ENOMEM;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5639
	netdev = alloc_etherdev(sizeof(struct e1000_adapter));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5640
	if (!netdev)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5641
		goto err_alloc_etherdev;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5642
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5643
	SET_NETDEV_DEV(netdev, &pdev->dev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5644
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5645
	netdev->irq = pdev->irq;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5646
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5647
	pci_set_drvdata(pdev, netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5648
	adapter = netdev_priv(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5649
	hw = &adapter->hw;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5650
	adapter->netdev = netdev;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5651
	adapter->pdev = pdev;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5652
	adapter->ei = ei;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5653
	adapter->pba = ei->pba;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5654
	adapter->flags = ei->flags;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5655
	adapter->flags2 = ei->flags2;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5656
	adapter->hw.adapter = adapter;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5657
	adapter->hw.mac.type = ei->mac;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5658
	adapter->max_hw_frame_size = ei->max_hw_frame_size;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5659
	adapter->msg_enable = (1 << NETIF_MSG_DRV | NETIF_MSG_PROBE) - 1;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5660
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5661
	mmio_start = pci_resource_start(pdev, 0);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5662
	mmio_len = pci_resource_len(pdev, 0);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5663
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5664
	err = -EIO;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5665
	adapter->hw.hw_addr = ioremap(mmio_start, mmio_len);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5666
	if (!adapter->hw.hw_addr)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5667
		goto err_ioremap;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5668
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5669
	if ((adapter->flags & FLAG_HAS_FLASH) &&
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5670
	    (pci_resource_flags(pdev, 1) & IORESOURCE_MEM)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5671
		flash_start = pci_resource_start(pdev, 1);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5672
		flash_len = pci_resource_len(pdev, 1);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5673
		adapter->hw.flash_address = ioremap(flash_start, flash_len);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5674
		if (!adapter->hw.flash_address)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5675
			goto err_flashmap;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5676
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5677
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5678
	/* construct the net_device struct */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5679
	netdev->netdev_ops		= &e1000e_netdev_ops;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5680
	e1000e_set_ethtool_ops(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5681
	netdev->watchdog_timeo		= 5 * HZ;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5682
	netif_napi_add(netdev, &adapter->napi, e1000_clean, 64);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5683
	strncpy(netdev->name, pci_name(pdev), sizeof(netdev->name) - 1);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5684
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5685
	netdev->mem_start = mmio_start;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5686
	netdev->mem_end = mmio_start + mmio_len;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5687
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5688
	adapter->bd_number = cards_found++;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5689
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5690
	e1000e_check_options(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5691
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5692
	/* setup adapter struct */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5693
	err = e1000_sw_init(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5694
	if (err)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5695
		goto err_sw_init;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5696
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5697
	err = -EIO;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5698
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5699
	memcpy(&hw->mac.ops, ei->mac_ops, sizeof(hw->mac.ops));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5700
	memcpy(&hw->nvm.ops, ei->nvm_ops, sizeof(hw->nvm.ops));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5701
	memcpy(&hw->phy.ops, ei->phy_ops, sizeof(hw->phy.ops));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5702
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5703
	err = ei->get_variants(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5704
	if (err)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5705
		goto err_hw_init;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5706
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5707
	if ((adapter->flags & FLAG_IS_ICH) &&
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5708
	    (adapter->flags & FLAG_READ_ONLY_NVM))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5709
		e1000e_write_protect_nvm_ich8lan(&adapter->hw);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5710
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5711
	hw->mac.ops.get_bus_info(&adapter->hw);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5712
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5713
	adapter->hw.phy.autoneg_wait_to_complete = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5714
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5715
	/* Copper options */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5716
	if (adapter->hw.phy.media_type == e1000_media_type_copper) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5717
		adapter->hw.phy.mdix = AUTO_ALL_MODES;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5718
		adapter->hw.phy.disable_polarity_correction = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5719
		adapter->hw.phy.ms_type = e1000_ms_hw_default;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5720
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5721
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5722
	if (e1000_check_reset_block(&adapter->hw))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5723
		e_info("PHY reset is blocked due to SOL/IDER session.\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5724
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5725
	netdev->features = NETIF_F_SG |
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5726
			   NETIF_F_HW_CSUM |
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5727
			   NETIF_F_HW_VLAN_TX |
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5728
			   NETIF_F_HW_VLAN_RX;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5729
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5730
	if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5731
		netdev->features |= NETIF_F_HW_VLAN_FILTER;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5732
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5733
	netdev->features |= NETIF_F_TSO;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5734
	netdev->features |= NETIF_F_TSO6;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5735
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5736
	netdev->vlan_features |= NETIF_F_TSO;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5737
	netdev->vlan_features |= NETIF_F_TSO6;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5738
	netdev->vlan_features |= NETIF_F_HW_CSUM;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5739
	netdev->vlan_features |= NETIF_F_SG;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5740
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5741
	if (pci_using_dac)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5742
		netdev->features |= NETIF_F_HIGHDMA;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5743
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5744
	if (e1000e_enable_mng_pass_thru(&adapter->hw))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5745
		adapter->flags |= FLAG_MNG_PT_ENABLED;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5746
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5747
	/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5748
	 * before reading the NVM, reset the controller to
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5749
	 * put the device in a known good starting state
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5750
	 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5751
	adapter->hw.mac.ops.reset_hw(&adapter->hw);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5752
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5753
	/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5754
	 * systems with ASPM and others may see the checksum fail on the first
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5755
	 * attempt. Let's give it a few tries
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5756
	 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5757
	for (i = 0;; i++) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5758
		if (e1000_validate_nvm_checksum(&adapter->hw) >= 0)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5759
			break;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5760
		if (i == 2) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5761
			e_err("The NVM Checksum Is Not Valid\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5762
			err = -EIO;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5763
			goto err_eeprom;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5764
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5765
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5766
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5767
	e1000_eeprom_checks(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5768
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5769
	/* copy the MAC address */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5770
	if (e1000e_read_mac_addr(&adapter->hw))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5771
		e_err("NVM Read Error while reading MAC address\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5772
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5773
	memcpy(netdev->dev_addr, adapter->hw.mac.addr, netdev->addr_len);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5774
	memcpy(netdev->perm_addr, adapter->hw.mac.addr, netdev->addr_len);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5775
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5776
	if (!is_valid_ether_addr(netdev->perm_addr)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5777
		e_err("Invalid MAC Address: %pM\n", netdev->perm_addr);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5778
		err = -EIO;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5779
		goto err_eeprom;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5780
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5781
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5782
	init_timer(&adapter->watchdog_timer);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5783
	adapter->watchdog_timer.function = &e1000_watchdog;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5784
	adapter->watchdog_timer.data = (unsigned long) adapter;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5785
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5786
	init_timer(&adapter->phy_info_timer);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5787
	adapter->phy_info_timer.function = &e1000_update_phy_info;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5788
	adapter->phy_info_timer.data = (unsigned long) adapter;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5789
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5790
	INIT_WORK(&adapter->reset_task, e1000_reset_task);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5791
	INIT_WORK(&adapter->watchdog_task, e1000_watchdog_task);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5792
	INIT_WORK(&adapter->downshift_task, e1000e_downshift_workaround);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5793
	INIT_WORK(&adapter->update_phy_task, e1000e_update_phy_task);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5794
	INIT_WORK(&adapter->print_hang_task, e1000_print_hw_hang);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5795
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5796
	/* Initialize link parameters. User can change them with ethtool */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5797
	adapter->hw.mac.autoneg = 1;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5798
	adapter->fc_autoneg = 1;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5799
	adapter->hw.fc.requested_mode = e1000_fc_default;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5800
	adapter->hw.fc.current_mode = e1000_fc_default;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5801
	adapter->hw.phy.autoneg_advertised = 0x2f;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5802
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5803
	/* ring size defaults */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5804
	adapter->rx_ring->count = 256;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5805
	adapter->tx_ring->count = 256;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5806
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5807
	/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5808
	 * Initial Wake on LAN setting - If APM wake is enabled in
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5809
	 * the EEPROM, enable the ACPI Magic Packet filter
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5810
	 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5811
	if (adapter->flags & FLAG_APME_IN_WUC) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5812
		/* APME bit in EEPROM is mapped to WUC.APME */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5813
		eeprom_data = er32(WUC);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5814
		eeprom_apme_mask = E1000_WUC_APME;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5815
		if (eeprom_data & E1000_WUC_PHY_WAKE)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5816
			adapter->flags2 |= FLAG2_HAS_PHY_WAKEUP;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5817
	} else if (adapter->flags & FLAG_APME_IN_CTRL3) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5818
		if (adapter->flags & FLAG_APME_CHECK_PORT_B &&
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5819
		    (adapter->hw.bus.func == 1))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5820
			e1000_read_nvm(&adapter->hw,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5821
				NVM_INIT_CONTROL3_PORT_B, 1, &eeprom_data);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5822
		else
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5823
			e1000_read_nvm(&adapter->hw,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5824
				NVM_INIT_CONTROL3_PORT_A, 1, &eeprom_data);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5825
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5826
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5827
	/* fetch WoL from EEPROM */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5828
	if (eeprom_data & eeprom_apme_mask)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5829
		adapter->eeprom_wol |= E1000_WUFC_MAG;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5830
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5831
	/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5832
	 * now that we have the eeprom settings, apply the special cases
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5833
	 * where the eeprom may be wrong or the board simply won't support
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5834
	 * wake on lan on a particular port
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5835
	 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5836
	if (!(adapter->flags & FLAG_HAS_WOL))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5837
		adapter->eeprom_wol = 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5838
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5839
	/* initialize the wol settings based on the eeprom settings */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5840
	adapter->wol = adapter->eeprom_wol;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5841
	device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5842
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5843
	/* save off EEPROM version number */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5844
	e1000_read_nvm(&adapter->hw, 5, 1, &adapter->eeprom_vers);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5845
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5846
	/* reset the hardware with the new settings */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5847
	e1000e_reset(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5848
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5849
	/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5850
	 * If the controller has AMT, do not set DRV_LOAD until the interface
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5851
	 * is up.  For all other cases, let the f/w know that the h/w is now
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5852
	 * under the control of the driver.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5853
	 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5854
	if (!(adapter->flags & FLAG_HAS_AMT))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5855
		e1000_get_hw_control(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5856
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5857
	adapter->ecdev = ecdev_offer(netdev,ec_poll,THIS_MODULE);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5858
	if (adapter->ecdev) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5859
		if (ecdev_open(adapter->ecdev)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5860
			ecdev_withdraw(adapter->ecdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5861
			goto err_register;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5862
		}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5863
	} else {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5864
		strcpy(netdev->name, "eth%d");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5865
		err = register_netdev(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5866
		if (err)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5867
			goto err_register;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5868
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5869
		/* carrier off reporting is important to ethtool even BEFORE open */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5870
		netif_carrier_off(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5871
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5872
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5873
	e1000_print_device_info(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5874
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5875
	if (pci_dev_run_wake(pdev)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5876
		pm_runtime_set_active(&pdev->dev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5877
		pm_runtime_enable(&pdev->dev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5878
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5879
	pm_schedule_suspend(&pdev->dev, MSEC_PER_SEC);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5880
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5881
	return 0;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5882
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5883
err_register:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5884
	if (!(adapter->flags & FLAG_HAS_AMT))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5885
		e1000_release_hw_control(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5886
err_eeprom:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5887
	if (!e1000_check_reset_block(&adapter->hw))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5888
		e1000_phy_hw_reset(&adapter->hw);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5889
err_hw_init:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5890
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5891
	kfree(adapter->tx_ring);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5892
	kfree(adapter->rx_ring);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5893
err_sw_init:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5894
	if (adapter->hw.flash_address)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5895
		iounmap(adapter->hw.flash_address);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5896
	e1000e_reset_interrupt_capability(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5897
err_flashmap:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5898
	iounmap(adapter->hw.hw_addr);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5899
err_ioremap:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5900
	free_netdev(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5901
err_alloc_etherdev:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5902
	pci_release_selected_regions(pdev,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5903
	                             pci_select_bars(pdev, IORESOURCE_MEM));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5904
err_pci_reg:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5905
err_dma:
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5906
	pci_disable_device(pdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5907
	return err;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5908
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5909
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5910
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5911
 * e1000_remove - Device Removal Routine
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5912
 * @pdev: PCI device information struct
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5913
 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5914
 * e1000_remove is called by the PCI subsystem to alert the driver
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5915
 * that it should release a PCI device.  The could be caused by a
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5916
 * Hot-Plug event, or because the driver is going to be removed from
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5917
 * memory.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5918
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5919
static void __devexit e1000_remove(struct pci_dev *pdev)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5920
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5921
	struct net_device *netdev = pci_get_drvdata(pdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5922
	struct e1000_adapter *adapter = netdev_priv(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5923
	bool down = test_bit(__E1000_DOWN, &adapter->state);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5924
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5925
	pm_runtime_get_sync(&pdev->dev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5926
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5927
	/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5928
	 * flush_scheduled work may reschedule our watchdog task, so
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5929
	 * explicitly disable watchdog tasks from being rescheduled
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5930
	 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5931
	if (!down)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5932
		set_bit(__E1000_DOWN, &adapter->state);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5933
	del_timer_sync(&adapter->watchdog_timer);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5934
	del_timer_sync(&adapter->phy_info_timer);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5935
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5936
	cancel_work_sync(&adapter->reset_task);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5937
	cancel_work_sync(&adapter->watchdog_task);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5938
	cancel_work_sync(&adapter->downshift_task);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5939
	cancel_work_sync(&adapter->update_phy_task);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5940
	cancel_work_sync(&adapter->print_hang_task);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5941
	flush_scheduled_work();
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5942
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5943
	if (!(netdev->flags & IFF_UP))
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5944
		e1000_power_down_phy(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5945
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5946
	/* Don't lie to e1000_close() down the road. */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5947
	if (!down)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5948
		clear_bit(__E1000_DOWN, &adapter->state);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5949
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5950
	if (adapter->ecdev) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5951
		ecdev_close(adapter->ecdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5952
		ecdev_withdraw(adapter->ecdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5953
	} else {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5954
		unregister_netdev(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5955
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5956
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5957
	if (pci_dev_run_wake(pdev)) {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5958
		pm_runtime_disable(&pdev->dev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5959
		pm_runtime_set_suspended(&pdev->dev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5960
	}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5961
	pm_runtime_put_noidle(&pdev->dev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5962
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5963
	/*
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5964
	 * Release control of h/w to f/w.  If f/w is AMT enabled, this
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5965
	 * would have already happened in close and is redundant.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5966
	 */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5967
	e1000_release_hw_control(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5968
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5969
	e1000e_reset_interrupt_capability(adapter);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5970
	kfree(adapter->tx_ring);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5971
	kfree(adapter->rx_ring);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5972
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5973
	iounmap(adapter->hw.hw_addr);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5974
	if (adapter->hw.flash_address)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5975
		iounmap(adapter->hw.flash_address);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5976
	pci_release_selected_regions(pdev,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5977
	                             pci_select_bars(pdev, IORESOURCE_MEM));
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5978
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5979
	free_netdev(netdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5980
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5981
	/* AER disable */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5982
	pci_disable_pcie_error_reporting(pdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5983
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5984
	pci_disable_device(pdev);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5985
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5986
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5987
/* PCI Error Recovery (ERS) */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5988
static struct pci_error_handlers e1000_err_handler = {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5989
	.error_detected = e1000_io_error_detected,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5990
	.slot_reset = e1000_io_slot_reset,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5991
	.resume = e1000_io_resume,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5992
};
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5993
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5994
static DEFINE_PCI_DEVICE_TABLE(e1000_pci_tbl) = {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5995
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_COPPER), board_82571 },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5996
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_FIBER), board_82571 },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5997
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_QUAD_COPPER), board_82571 },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5998
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_QUAD_COPPER_LP), board_82571 },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5999
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_QUAD_FIBER), board_82571 },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6000
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_SERDES), board_82571 },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6001
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_SERDES_DUAL), board_82571 },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6002
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_SERDES_QUAD), board_82571 },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6003
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82571PT_QUAD_COPPER), board_82571 },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6004
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6005
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82572EI), board_82572 },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6006
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82572EI_COPPER), board_82572 },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6007
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82572EI_FIBER), board_82572 },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6008
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82572EI_SERDES), board_82572 },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6009
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6010
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82573E), board_82573 },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6011
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82573E_IAMT), board_82573 },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6012
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82573L), board_82573 },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6013
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6014
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82574L), board_82574 },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6015
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82574LA), board_82574 },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6016
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82583V), board_82583 },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6017
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6018
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_80003ES2LAN_COPPER_DPT),
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6019
	  board_80003es2lan },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6020
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_80003ES2LAN_COPPER_SPT),
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6021
	  board_80003es2lan },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6022
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_80003ES2LAN_SERDES_DPT),
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6023
	  board_80003es2lan },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6024
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_80003ES2LAN_SERDES_SPT),
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6025
	  board_80003es2lan },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6026
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6027
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH8_IFE), board_ich8lan },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6028
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH8_IFE_G), board_ich8lan },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6029
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH8_IFE_GT), board_ich8lan },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6030
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH8_IGP_AMT), board_ich8lan },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6031
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH8_IGP_C), board_ich8lan },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6032
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH8_IGP_M), board_ich8lan },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6033
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH8_IGP_M_AMT), board_ich8lan },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6034
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH8_82567V_3), board_ich8lan },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6035
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6036
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IFE), board_ich9lan },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6037
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IFE_G), board_ich9lan },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6038
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IFE_GT), board_ich9lan },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6039
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IGP_AMT), board_ich9lan },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6040
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IGP_C), board_ich9lan },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6041
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_BM), board_ich9lan },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6042
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IGP_M), board_ich9lan },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6043
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IGP_M_AMT), board_ich9lan },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6044
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IGP_M_V), board_ich9lan },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6045
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6046
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH10_R_BM_LM), board_ich9lan },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6047
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH10_R_BM_LF), board_ich9lan },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6048
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH10_R_BM_V), board_ich9lan },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6049
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6050
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH10_D_BM_LM), board_ich10lan },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6051
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH10_D_BM_LF), board_ich10lan },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6052
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH10_D_BM_V), board_ich10lan },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6053
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6054
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_M_HV_LM), board_pchlan },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6055
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_M_HV_LC), board_pchlan },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6056
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_D_HV_DM), board_pchlan },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6057
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_D_HV_DC), board_pchlan },
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6058
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6059
	{ }	/* terminate list */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6060
};
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6061
//MODULE_DEVICE_TABLE(pci, e1000_pci_tbl);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6062
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6063
#ifdef CONFIG_PM_OPS
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6064
static const struct dev_pm_ops e1000_pm_ops = {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6065
	SET_SYSTEM_SLEEP_PM_OPS(e1000_suspend, e1000_resume)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6066
	SET_RUNTIME_PM_OPS(e1000_runtime_suspend,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6067
				e1000_runtime_resume, e1000_idle)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6068
};
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6069
#endif
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6070
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6071
/* PCI Device API Driver */
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6072
static struct pci_driver e1000_driver = {
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6073
	.name     = e1000e_driver_name,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6074
	.id_table = e1000_pci_tbl,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6075
	.probe    = e1000_probe,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6076
	.remove   = __devexit_p(e1000_remove),
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6077
#ifdef CONFIG_PM_OPS
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6078
	.driver.pm = &e1000_pm_ops,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6079
#endif
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6080
	.shutdown = e1000_shutdown,
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6081
	.err_handler = &e1000_err_handler
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6082
};
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6083
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6084
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6085
 * e1000_init_module - Driver Registration Routine
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6086
 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6087
 * e1000_init_module is the first routine called when the driver is
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6088
 * loaded. All it does is register with the PCI subsystem.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6089
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6090
static int __init e1000_init_module(void)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6091
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6092
	int ret;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6093
	pr_info("EtherCAT-capable Intel(R) PRO/1000 Network Driver - %s\n",
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6094
		e1000e_driver_version);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6095
	pr_info("Copyright (c) 1999 - 2009 Intel Corporation.\n");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6096
	ret = pci_register_driver(&e1000_driver);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6097
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6098
	return ret;
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6099
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6100
module_init(e1000_init_module);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6101
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6102
/**
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6103
 * e1000_exit_module - Driver Exit Cleanup Routine
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6104
 *
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6105
 * e1000_exit_module is called just before the driver is removed
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6106
 * from memory.
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6107
 **/
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6108
static void __exit e1000_exit_module(void)
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6109
{
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6110
	pci_unregister_driver(&e1000_driver);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6111
}
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6112
module_exit(e1000_exit_module);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6113
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6114
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6115
MODULE_AUTHOR("Intel Corporation, <linux.nics@intel.com>");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6116
MODULE_DESCRIPTION("Ethercat-capable Intel(R) PRO/1000 Network Driver");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6117
MODULE_LICENSE("GPL");
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6118
MODULE_VERSION(DRV_VERSION);
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6119
dce13f854817 Added e1000e driver for 2.6.35.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6120
/* e1000_main.c */