devices/e1000e/netdev-3.2-ethercat.c
author Gavin Lambert <gavinl@compacsort.com>
Tue, 14 Apr 2015 09:35:15 -0400
changeset 2620 0e4d098db815
parent 2589 2b9c78543663
permissions -rw-r--r--
Abort requests started for slave_configs that don't have any actual slaves.
2406
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/*******************************************************************************
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
  Intel PRO/1000 Linux driver
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
  Copyright(c) 1999 - 2011 Intel Corporation.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     5
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     6
  This program is free software; you can redistribute it and/or modify it
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     7
  under the terms and conditions of the GNU General Public License,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
  version 2, as published by the Free Software Foundation.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     9
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    10
  This program is distributed in the hope it will be useful, but WITHOUT
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    11
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    12
  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
  more details.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    14
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    15
  You should have received a copy of the GNU General Public License along with
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    16
  this program; if not, write to the Free Software Foundation, Inc.,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    17
  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    18
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    19
  The full GNU General Public License is included in this distribution in
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    20
  the file called "COPYING".
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    21
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    22
  Contact Information:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    23
  Linux NICS <linux.nics@intel.com>
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    24
  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    25
  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    26
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
    27
  vim: noexpandtab
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
    28
2406
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
*******************************************************************************/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
#include <linux/module.h>
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
#include <linux/types.h>
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
#include <linux/init.h>
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
#include <linux/pci.h>
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
#include <linux/vmalloc.h>
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
#include <linux/pagemap.h>
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    39
#include <linux/delay.h>
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
#include <linux/netdevice.h>
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
#include <linux/interrupt.h>
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
#include <linux/tcp.h>
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
#include <linux/ipv6.h>
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
#include <linux/slab.h>
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
#include <net/checksum.h>
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
#include <net/ip6_checksum.h>
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
#include <linux/mii.h>
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    48
#include <linux/ethtool.h>
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    49
#include <linux/if_vlan.h>
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    50
#include <linux/cpu.h>
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    51
#include <linux/smp.h>
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    52
#include <linux/pm_qos.h>
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    53
#include <linux/pm_runtime.h>
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    54
#include <linux/aer.h>
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    55
#include <linux/prefetch.h>
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    56
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    57
#include "e1000-3.2-ethercat.h"
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    58
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    59
#define DRV_EXTRAVERSION "-k-EtherCAT"
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    60
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    61
#define DRV_VERSION "1.5.1" DRV_EXTRAVERSION
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    62
char e1000e_driver_name[] = "ec_e1000e";
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    63
const char e1000e_driver_version[] = DRV_VERSION;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    64
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    65
static void e1000e_disable_aspm(struct pci_dev *pdev, u16 state);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    66
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    67
static const struct e1000_info *e1000_info_tbl[] = {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    68
	[board_82571]		= &e1000_82571_info,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    69
	[board_82572]		= &e1000_82572_info,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    70
	[board_82573]		= &e1000_82573_info,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    71
	[board_82574]		= &e1000_82574_info,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    72
	[board_82583]		= &e1000_82583_info,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    73
	[board_80003es2lan]	= &e1000_es2_info,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    74
	[board_ich8lan]		= &e1000_ich8_info,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    75
	[board_ich9lan]		= &e1000_ich9_info,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    76
	[board_ich10lan]	= &e1000_ich10_info,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    77
	[board_pchlan]		= &e1000_pch_info,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    78
	[board_pch2lan]		= &e1000_pch2_info,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    79
};
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    80
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    81
struct e1000_reg_info {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    82
	u32 ofs;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    83
	char *name;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    84
};
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    85
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    86
#define E1000_RDFH	0x02410	/* Rx Data FIFO Head - RW */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    87
#define E1000_RDFT	0x02418	/* Rx Data FIFO Tail - RW */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    88
#define E1000_RDFHS	0x02420	/* Rx Data FIFO Head Saved - RW */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    89
#define E1000_RDFTS	0x02428	/* Rx Data FIFO Tail Saved - RW */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    90
#define E1000_RDFPC	0x02430	/* Rx Data FIFO Packet Count - RW */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    91
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    92
#define E1000_TDFH	0x03410	/* Tx Data FIFO Head - RW */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    93
#define E1000_TDFT	0x03418	/* Tx Data FIFO Tail - RW */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    94
#define E1000_TDFHS	0x03420	/* Tx Data FIFO Head Saved - RW */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    95
#define E1000_TDFTS	0x03428	/* Tx Data FIFO Tail Saved - RW */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    96
#define E1000_TDFPC	0x03430	/* Tx Data FIFO Packet Count - RW */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    97
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    98
static const struct e1000_reg_info e1000_reg_info_tbl[] = {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    99
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   100
	/* General Registers */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   101
	{E1000_CTRL, "CTRL"},
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   102
	{E1000_STATUS, "STATUS"},
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   103
	{E1000_CTRL_EXT, "CTRL_EXT"},
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   104
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   105
	/* Interrupt Registers */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   106
	{E1000_ICR, "ICR"},
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   107
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   108
	/* Rx Registers */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   109
	{E1000_RCTL, "RCTL"},
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   110
	{E1000_RDLEN, "RDLEN"},
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   111
	{E1000_RDH, "RDH"},
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   112
	{E1000_RDT, "RDT"},
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   113
	{E1000_RDTR, "RDTR"},
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   114
	{E1000_RXDCTL(0), "RXDCTL"},
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   115
	{E1000_ERT, "ERT"},
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   116
	{E1000_RDBAL, "RDBAL"},
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   117
	{E1000_RDBAH, "RDBAH"},
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   118
	{E1000_RDFH, "RDFH"},
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   119
	{E1000_RDFT, "RDFT"},
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   120
	{E1000_RDFHS, "RDFHS"},
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   121
	{E1000_RDFTS, "RDFTS"},
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   122
	{E1000_RDFPC, "RDFPC"},
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   123
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   124
	/* Tx Registers */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   125
	{E1000_TCTL, "TCTL"},
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   126
	{E1000_TDBAL, "TDBAL"},
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   127
	{E1000_TDBAH, "TDBAH"},
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   128
	{E1000_TDLEN, "TDLEN"},
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   129
	{E1000_TDH, "TDH"},
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   130
	{E1000_TDT, "TDT"},
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   131
	{E1000_TIDV, "TIDV"},
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   132
	{E1000_TXDCTL(0), "TXDCTL"},
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   133
	{E1000_TADV, "TADV"},
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   134
	{E1000_TARC(0), "TARC"},
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   135
	{E1000_TDFH, "TDFH"},
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   136
	{E1000_TDFT, "TDFT"},
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   137
	{E1000_TDFHS, "TDFHS"},
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   138
	{E1000_TDFTS, "TDFTS"},
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   139
	{E1000_TDFPC, "TDFPC"},
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   140
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   141
	/* List Terminator */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   142
	{}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   143
};
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   144
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   145
/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   146
 * e1000_regdump - register printout routine
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   147
 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   148
static void e1000_regdump(struct e1000_hw *hw, struct e1000_reg_info *reginfo)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   149
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   150
	int n = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   151
	char rname[16];
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   152
	u32 regs[8];
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   153
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   154
	switch (reginfo->ofs) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   155
	case E1000_RXDCTL(0):
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   156
		for (n = 0; n < 2; n++)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   157
			regs[n] = __er32(hw, E1000_RXDCTL(n));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   158
		break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   159
	case E1000_TXDCTL(0):
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   160
		for (n = 0; n < 2; n++)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   161
			regs[n] = __er32(hw, E1000_TXDCTL(n));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   162
		break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   163
	case E1000_TARC(0):
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   164
		for (n = 0; n < 2; n++)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   165
			regs[n] = __er32(hw, E1000_TARC(n));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   166
		break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   167
	default:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   168
		printk(KERN_INFO "%-15s %08x\n",
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   169
		       reginfo->name, __er32(hw, reginfo->ofs));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   170
		return;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   171
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   172
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   173
	snprintf(rname, 16, "%s%s", reginfo->name, "[0-1]");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   174
	printk(KERN_INFO "%-15s ", rname);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   175
	for (n = 0; n < 2; n++)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   176
		printk(KERN_CONT "%08x ", regs[n]);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   177
	printk(KERN_CONT "\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   178
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   179
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   180
/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   181
 * e1000e_dump - Print registers, Tx-ring and Rx-ring
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   182
 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   183
static void e1000e_dump(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   184
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   185
	struct net_device *netdev = adapter->netdev;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   186
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   187
	struct e1000_reg_info *reginfo;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   188
	struct e1000_ring *tx_ring = adapter->tx_ring;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   189
	struct e1000_tx_desc *tx_desc;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   190
	struct my_u0 {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   191
		u64 a;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   192
		u64 b;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   193
	} *u0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   194
	struct e1000_buffer *buffer_info;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   195
	struct e1000_ring *rx_ring = adapter->rx_ring;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   196
	union e1000_rx_desc_packet_split *rx_desc_ps;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   197
	union e1000_rx_desc_extended *rx_desc;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   198
	struct my_u1 {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   199
		u64 a;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   200
		u64 b;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   201
		u64 c;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   202
		u64 d;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   203
	} *u1;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   204
	u32 staterr;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   205
	int i = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   206
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   207
	if (!netif_msg_hw(adapter))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   208
		return;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   209
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   210
	/* Print netdevice Info */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   211
	if (netdev) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   212
		dev_info(&adapter->pdev->dev, "Net device Info\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   213
		printk(KERN_INFO "Device Name     state            "
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   214
		       "trans_start      last_rx\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   215
		printk(KERN_INFO "%-15s %016lX %016lX %016lX\n",
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   216
		       netdev->name, netdev->state, netdev->trans_start,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   217
		       netdev->last_rx);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   218
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   219
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   220
	/* Print Registers */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   221
	dev_info(&adapter->pdev->dev, "Register Dump\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   222
	printk(KERN_INFO " Register Name   Value\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   223
	for (reginfo = (struct e1000_reg_info *)e1000_reg_info_tbl;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   224
	     reginfo->name; reginfo++) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   225
		e1000_regdump(hw, reginfo);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   226
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   227
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   228
	/* Print Tx Ring Summary */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   229
	if (!netdev || !netif_running(netdev))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   230
		goto exit;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   231
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   232
	dev_info(&adapter->pdev->dev, "Tx Ring Summary\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   233
	printk(KERN_INFO "Queue [NTU] [NTC] [bi(ntc)->dma  ]"
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   234
	       " leng ntw timestamp\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   235
	buffer_info = &tx_ring->buffer_info[tx_ring->next_to_clean];
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   236
	printk(KERN_INFO " %5d %5X %5X %016llX %04X %3X %016llX\n",
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   237
	       0, tx_ring->next_to_use, tx_ring->next_to_clean,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   238
	       (unsigned long long)buffer_info->dma,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   239
	       buffer_info->length,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   240
	       buffer_info->next_to_watch,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   241
	       (unsigned long long)buffer_info->time_stamp);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   242
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   243
	/* Print Tx Ring */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   244
	if (!netif_msg_tx_done(adapter))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   245
		goto rx_ring_summary;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   246
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   247
	dev_info(&adapter->pdev->dev, "Tx Ring Dump\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   248
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   249
	/* Transmit Descriptor Formats - DEXT[29] is 0 (Legacy) or 1 (Extended)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   250
	 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   251
	 * Legacy Transmit Descriptor
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   252
	 *   +--------------------------------------------------------------+
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   253
	 * 0 |         Buffer Address [63:0] (Reserved on Write Back)       |
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   254
	 *   +--------------------------------------------------------------+
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   255
	 * 8 | Special  |    CSS     | Status |  CMD    |  CSO   |  Length  |
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   256
	 *   +--------------------------------------------------------------+
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   257
	 *   63       48 47        36 35    32 31     24 23    16 15        0
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   258
	 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   259
	 * Extended Context Descriptor (DTYP=0x0) for TSO or checksum offload
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   260
	 *   63      48 47    40 39       32 31             16 15    8 7      0
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   261
	 *   +----------------------------------------------------------------+
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   262
	 * 0 |  TUCSE  | TUCS0  |   TUCSS   |     IPCSE       | IPCS0 | IPCSS |
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   263
	 *   +----------------------------------------------------------------+
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   264
	 * 8 |   MSS   | HDRLEN | RSV | STA | TUCMD | DTYP |      PAYLEN      |
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   265
	 *   +----------------------------------------------------------------+
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   266
	 *   63      48 47    40 39 36 35 32 31   24 23  20 19                0
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   267
	 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   268
	 * Extended Data Descriptor (DTYP=0x1)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   269
	 *   +----------------------------------------------------------------+
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   270
	 * 0 |                     Buffer Address [63:0]                      |
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   271
	 *   +----------------------------------------------------------------+
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   272
	 * 8 | VLAN tag |  POPTS  | Rsvd | Status | Command | DTYP |  DTALEN  |
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   273
	 *   +----------------------------------------------------------------+
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   274
	 *   63       48 47     40 39  36 35    32 31     24 23  20 19        0
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   275
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   276
	printk(KERN_INFO "Tl[desc]     [address 63:0  ] [SpeCssSCmCsLen]"
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   277
	       " [bi->dma       ] leng  ntw timestamp        bi->skb "
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   278
	       "<-- Legacy format\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   279
	printk(KERN_INFO "Tc[desc]     [Ce CoCsIpceCoS] [MssHlRSCm0Plen]"
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   280
	       " [bi->dma       ] leng  ntw timestamp        bi->skb "
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   281
	       "<-- Ext Context format\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   282
	printk(KERN_INFO "Td[desc]     [address 63:0  ] [VlaPoRSCm1Dlen]"
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   283
	       " [bi->dma       ] leng  ntw timestamp        bi->skb "
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   284
	       "<-- Ext Data format\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   285
	for (i = 0; tx_ring->desc && (i < tx_ring->count); i++) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   286
		tx_desc = E1000_TX_DESC(*tx_ring, i);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   287
		buffer_info = &tx_ring->buffer_info[i];
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   288
		u0 = (struct my_u0 *)tx_desc;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   289
		printk(KERN_INFO "T%c[0x%03X]    %016llX %016llX %016llX "
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   290
		       "%04X  %3X %016llX %p",
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   291
		       (!(le64_to_cpu(u0->b) & (1 << 29)) ? 'l' :
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   292
			((le64_to_cpu(u0->b) & (1 << 20)) ? 'd' : 'c')), i,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   293
		       (unsigned long long)le64_to_cpu(u0->a),
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   294
		       (unsigned long long)le64_to_cpu(u0->b),
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   295
		       (unsigned long long)buffer_info->dma,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   296
		       buffer_info->length, buffer_info->next_to_watch,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   297
		       (unsigned long long)buffer_info->time_stamp,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   298
		       buffer_info->skb);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   299
		if (i == tx_ring->next_to_use && i == tx_ring->next_to_clean)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   300
			printk(KERN_CONT " NTC/U\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   301
		else if (i == tx_ring->next_to_use)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   302
			printk(KERN_CONT " NTU\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   303
		else if (i == tx_ring->next_to_clean)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   304
			printk(KERN_CONT " NTC\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   305
		else
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   306
			printk(KERN_CONT "\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   307
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   308
		if (netif_msg_pktdata(adapter) && buffer_info->dma != 0)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   309
			print_hex_dump(KERN_INFO, "", DUMP_PREFIX_ADDRESS,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   310
				       16, 1, phys_to_virt(buffer_info->dma),
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   311
				       buffer_info->length, true);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   312
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   313
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   314
	/* Print Rx Ring Summary */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   315
rx_ring_summary:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   316
	dev_info(&adapter->pdev->dev, "Rx Ring Summary\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   317
	printk(KERN_INFO "Queue [NTU] [NTC]\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   318
	printk(KERN_INFO " %5d %5X %5X\n", 0,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   319
	       rx_ring->next_to_use, rx_ring->next_to_clean);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   320
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   321
	/* Print Rx Ring */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   322
	if (!netif_msg_rx_status(adapter))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   323
		goto exit;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   324
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   325
	dev_info(&adapter->pdev->dev, "Rx Ring Dump\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   326
	switch (adapter->rx_ps_pages) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   327
	case 1:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   328
	case 2:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   329
	case 3:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   330
		/* [Extended] Packet Split Receive Descriptor Format
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   331
		 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   332
		 *    +-----------------------------------------------------+
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   333
		 *  0 |                Buffer Address 0 [63:0]              |
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   334
		 *    +-----------------------------------------------------+
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   335
		 *  8 |                Buffer Address 1 [63:0]              |
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   336
		 *    +-----------------------------------------------------+
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   337
		 * 16 |                Buffer Address 2 [63:0]              |
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   338
		 *    +-----------------------------------------------------+
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   339
		 * 24 |                Buffer Address 3 [63:0]              |
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   340
		 *    +-----------------------------------------------------+
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   341
		 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   342
		printk(KERN_INFO "R  [desc]      [buffer 0 63:0 ] "
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   343
		       "[buffer 1 63:0 ] "
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   344
		       "[buffer 2 63:0 ] [buffer 3 63:0 ] [bi->dma       ] "
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   345
		       "[bi->skb] <-- Ext Pkt Split format\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   346
		/* [Extended] Receive Descriptor (Write-Back) Format
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   347
		 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   348
		 *   63       48 47    32 31     13 12    8 7    4 3        0
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   349
		 *   +------------------------------------------------------+
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   350
		 * 0 | Packet   | IP     |  Rsvd   | MRQ   | Rsvd | MRQ RSS |
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   351
		 *   | Checksum | Ident  |         | Queue |      |  Type   |
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   352
		 *   +------------------------------------------------------+
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   353
		 * 8 | VLAN Tag | Length | Extended Error | Extended Status |
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   354
		 *   +------------------------------------------------------+
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   355
		 *   63       48 47    32 31            20 19               0
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   356
		 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   357
		printk(KERN_INFO "RWB[desc]      [ck ipid mrqhsh] "
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   358
		       "[vl   l0 ee  es] "
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   359
		       "[ l3  l2  l1 hs] [reserved      ] ---------------- "
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   360
		       "[bi->skb] <-- Ext Rx Write-Back format\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   361
		for (i = 0; i < rx_ring->count; i++) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   362
			buffer_info = &rx_ring->buffer_info[i];
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   363
			rx_desc_ps = E1000_RX_DESC_PS(*rx_ring, i);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   364
			u1 = (struct my_u1 *)rx_desc_ps;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   365
			staterr =
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   366
			    le32_to_cpu(rx_desc_ps->wb.middle.status_error);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   367
			if (staterr & E1000_RXD_STAT_DD) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   368
				/* Descriptor Done */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   369
				printk(KERN_INFO "RWB[0x%03X]     %016llX "
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   370
				       "%016llX %016llX %016llX "
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   371
				       "---------------- %p", i,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   372
				       (unsigned long long)le64_to_cpu(u1->a),
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   373
				       (unsigned long long)le64_to_cpu(u1->b),
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   374
				       (unsigned long long)le64_to_cpu(u1->c),
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   375
				       (unsigned long long)le64_to_cpu(u1->d),
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   376
				       buffer_info->skb);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   377
			} else {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   378
				printk(KERN_INFO "R  [0x%03X]     %016llX "
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   379
				       "%016llX %016llX %016llX %016llX %p", i,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   380
				       (unsigned long long)le64_to_cpu(u1->a),
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   381
				       (unsigned long long)le64_to_cpu(u1->b),
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   382
				       (unsigned long long)le64_to_cpu(u1->c),
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   383
				       (unsigned long long)le64_to_cpu(u1->d),
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   384
				       (unsigned long long)buffer_info->dma,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   385
				       buffer_info->skb);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   386
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   387
				if (netif_msg_pktdata(adapter))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   388
					print_hex_dump(KERN_INFO, "",
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   389
						DUMP_PREFIX_ADDRESS, 16, 1,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   390
						phys_to_virt(buffer_info->dma),
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   391
						adapter->rx_ps_bsize0, true);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   392
			}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   393
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   394
			if (i == rx_ring->next_to_use)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   395
				printk(KERN_CONT " NTU\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   396
			else if (i == rx_ring->next_to_clean)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   397
				printk(KERN_CONT " NTC\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   398
			else
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   399
				printk(KERN_CONT "\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   400
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   401
		break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   402
	default:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   403
	case 0:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   404
		/* Extended Receive Descriptor (Read) Format
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   405
		 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   406
		 *   +-----------------------------------------------------+
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   407
		 * 0 |                Buffer Address [63:0]                |
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   408
		 *   +-----------------------------------------------------+
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   409
		 * 8 |                      Reserved                       |
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   410
		 *   +-----------------------------------------------------+
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   411
		 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   412
		printk(KERN_INFO "R  [desc]      [buf addr 63:0 ] "
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   413
		       "[reserved 63:0 ] [bi->dma       ] "
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   414
		       "[bi->skb] <-- Ext (Read) format\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   415
		/* Extended Receive Descriptor (Write-Back) Format
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   416
		 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   417
		 *   63       48 47    32 31    24 23            4 3        0
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   418
		 *   +------------------------------------------------------+
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   419
		 *   |     RSS Hash      |        |               |         |
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   420
		 * 0 +-------------------+  Rsvd  |   Reserved    | MRQ RSS |
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   421
		 *   | Packet   | IP     |        |               |  Type   |
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   422
		 *   | Checksum | Ident  |        |               |         |
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   423
		 *   +------------------------------------------------------+
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   424
		 * 8 | VLAN Tag | Length | Extended Error | Extended Status |
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   425
		 *   +------------------------------------------------------+
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   426
		 *   63       48 47    32 31            20 19               0
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   427
		 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   428
		printk(KERN_INFO "RWB[desc]      [cs ipid    mrq] "
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   429
		       "[vt   ln xe  xs] "
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   430
		       "[bi->skb] <-- Ext (Write-Back) format\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   431
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   432
		for (i = 0; i < rx_ring->count; i++) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   433
			buffer_info = &rx_ring->buffer_info[i];
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   434
			rx_desc = E1000_RX_DESC_EXT(*rx_ring, i);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   435
			u1 = (struct my_u1 *)rx_desc;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   436
			staterr = le32_to_cpu(rx_desc->wb.upper.status_error);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   437
			if (staterr & E1000_RXD_STAT_DD) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   438
				/* Descriptor Done */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   439
				printk(KERN_INFO "RWB[0x%03X]     %016llX "
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   440
				       "%016llX ---------------- %p", i,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   441
				       (unsigned long long)le64_to_cpu(u1->a),
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   442
				       (unsigned long long)le64_to_cpu(u1->b),
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   443
				       buffer_info->skb);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   444
			} else {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   445
				printk(KERN_INFO "R  [0x%03X]     %016llX "
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   446
				       "%016llX %016llX %p", i,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   447
				       (unsigned long long)le64_to_cpu(u1->a),
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   448
				       (unsigned long long)le64_to_cpu(u1->b),
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   449
				       (unsigned long long)buffer_info->dma,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   450
				       buffer_info->skb);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   451
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   452
				if (netif_msg_pktdata(adapter))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   453
					print_hex_dump(KERN_INFO, "",
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   454
						       DUMP_PREFIX_ADDRESS, 16,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   455
						       1,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   456
						       phys_to_virt
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   457
						       (buffer_info->dma),
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   458
						       adapter->rx_buffer_len,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   459
						       true);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   460
			}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   461
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   462
			if (i == rx_ring->next_to_use)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   463
				printk(KERN_CONT " NTU\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   464
			else if (i == rx_ring->next_to_clean)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   465
				printk(KERN_CONT " NTC\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   466
			else
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   467
				printk(KERN_CONT "\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   468
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   469
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   470
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   471
exit:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   472
	return;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   473
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   474
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   475
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   476
 * e1000_desc_unused - calculate if we have unused descriptors
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   477
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   478
static int e1000_desc_unused(struct e1000_ring *ring)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   479
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   480
	if (ring->next_to_clean > ring->next_to_use)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   481
		return ring->next_to_clean - ring->next_to_use - 1;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   482
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   483
	return ring->count + ring->next_to_clean - ring->next_to_use - 1;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   484
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   485
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   486
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   487
 * e1000_receive_skb - helper function to handle Rx indications
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   488
 * @adapter: board private structure
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   489
 * @status: descriptor status field as written by hardware
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   490
 * @vlan: descriptor vlan field as written by hardware (no le/be conversion)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   491
 * @skb: pointer to sk_buff to be indicated to stack
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   492
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   493
static void e1000_receive_skb(struct e1000_adapter *adapter,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   494
			      struct net_device *netdev, struct sk_buff *skb,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   495
			      u8 status, __le16 vlan)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   496
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   497
	u16 tag = le16_to_cpu(vlan);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   498
	skb->protocol = eth_type_trans(skb, netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   499
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   500
	if (status & E1000_RXD_STAT_VP)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   501
		__vlan_hwaccel_put_tag(skb, tag);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   502
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   503
	napi_gro_receive(&adapter->napi, skb);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   504
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   505
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   506
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   507
 * e1000_rx_checksum - Receive Checksum Offload
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   508
 * @adapter:     board private structure
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   509
 * @status_err:  receive descriptor status and error fields
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   510
 * @csum:	receive descriptor csum field
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   511
 * @sk_buff:     socket buffer with received data
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   512
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   513
static void e1000_rx_checksum(struct e1000_adapter *adapter, u32 status_err,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   514
			      u32 csum, struct sk_buff *skb)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   515
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   516
	u16 status = (u16)status_err;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   517
	u8 errors = (u8)(status_err >> 24);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   518
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   519
	skb_checksum_none_assert(skb);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   520
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   521
	/* Ignore Checksum bit is set */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   522
	if (status & E1000_RXD_STAT_IXSM)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   523
		return;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   524
	/* TCP/UDP checksum error bit is set */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   525
	if (errors & E1000_RXD_ERR_TCPE) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   526
		/* let the stack verify checksum errors */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   527
		adapter->hw_csum_err++;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   528
		return;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   529
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   530
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   531
	/* TCP/UDP Checksum has not been calculated */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   532
	if (!(status & (E1000_RXD_STAT_TCPCS | E1000_RXD_STAT_UDPCS)))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   533
		return;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   534
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   535
	/* It must be a TCP or UDP packet with a valid checksum */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   536
	if (status & E1000_RXD_STAT_TCPCS) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   537
		/* TCP checksum is good */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   538
		skb->ip_summed = CHECKSUM_UNNECESSARY;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   539
	} else {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   540
		/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   541
		 * IP fragment with UDP payload
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   542
		 * Hardware complements the payload checksum, so we undo it
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   543
		 * and then put the value in host order for further stack use.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   544
		 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   545
		__sum16 sum = (__force __sum16)htons(csum);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   546
		skb->csum = csum_unfold(~sum);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   547
		skb->ip_summed = CHECKSUM_COMPLETE;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   548
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   549
	adapter->hw_csum_good++;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   550
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   551
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   552
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   553
 * e1000e_update_tail_wa - helper function for e1000e_update_[rt]dt_wa()
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   554
 * @hw: pointer to the HW structure
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   555
 * @tail: address of tail descriptor register
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   556
 * @i: value to write to tail descriptor register
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   557
 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   558
 * When updating the tail register, the ME could be accessing Host CSR
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   559
 * registers at the same time.  Normally, this is handled in h/w by an
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   560
 * arbiter but on some parts there is a bug that acknowledges Host accesses
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   561
 * later than it should which could result in the descriptor register to
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   562
 * have an incorrect value.  Workaround this by checking the FWSM register
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   563
 * which has bit 24 set while ME is accessing Host CSR registers, wait
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   564
 * if it is set and try again a number of times.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   565
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   566
static inline s32 e1000e_update_tail_wa(struct e1000_hw *hw, u8 __iomem * tail,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   567
					unsigned int i)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   568
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   569
	unsigned int j = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   570
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   571
	while ((j++ < E1000_ICH_FWSM_PCIM2PCI_COUNT) &&
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   572
	       (er32(FWSM) & E1000_ICH_FWSM_PCIM2PCI))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   573
		udelay(50);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   574
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   575
	writel(i, tail);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   576
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   577
	if ((j == E1000_ICH_FWSM_PCIM2PCI_COUNT) && (i != readl(tail)))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   578
		return E1000_ERR_SWFW_SYNC;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   579
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   580
	return 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   581
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   582
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   583
static void e1000e_update_rdt_wa(struct e1000_adapter *adapter, unsigned int i)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   584
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   585
	u8 __iomem *tail = (adapter->hw.hw_addr + adapter->rx_ring->tail);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   586
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   587
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   588
	if (e1000e_update_tail_wa(hw, tail, i)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   589
		u32 rctl = er32(RCTL);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   590
		ew32(RCTL, rctl & ~E1000_RCTL_EN);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   591
		e_err("ME firmware caused invalid RDT - resetting\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   592
		schedule_work(&adapter->reset_task);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   593
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   594
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   595
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   596
static void e1000e_update_tdt_wa(struct e1000_adapter *adapter, unsigned int i)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   597
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   598
	u8 __iomem *tail = (adapter->hw.hw_addr + adapter->tx_ring->tail);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   599
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   600
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   601
	if (e1000e_update_tail_wa(hw, tail, i)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   602
		u32 tctl = er32(TCTL);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   603
		ew32(TCTL, tctl & ~E1000_TCTL_EN);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   604
		e_err("ME firmware caused invalid TDT - resetting\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   605
		schedule_work(&adapter->reset_task);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   606
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   607
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   608
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   609
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   610
 * e1000_alloc_rx_buffers - Replace used receive buffers
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   611
 * @adapter: address of board private structure
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   612
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   613
static void e1000_alloc_rx_buffers(struct e1000_adapter *adapter,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   614
				   int cleaned_count, gfp_t gfp)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   615
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   616
	struct net_device *netdev = adapter->netdev;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   617
	struct pci_dev *pdev = adapter->pdev;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   618
	struct e1000_ring *rx_ring = adapter->rx_ring;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   619
	union e1000_rx_desc_extended *rx_desc;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   620
	struct e1000_buffer *buffer_info;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   621
	struct sk_buff *skb;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   622
	unsigned int i;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   623
	unsigned int bufsz = adapter->rx_buffer_len;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   624
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   625
	i = rx_ring->next_to_use;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   626
	buffer_info = &rx_ring->buffer_info[i];
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   627
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   628
	while (cleaned_count--) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   629
		skb = buffer_info->skb;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   630
		if (skb) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   631
			skb_trim(skb, 0);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   632
			goto map_skb;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   633
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   634
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   635
		skb = __netdev_alloc_skb_ip_align(netdev, bufsz, gfp);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   636
		if (!skb) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   637
			/* Better luck next round */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   638
			adapter->alloc_rx_buff_failed++;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   639
			break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   640
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   641
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   642
		buffer_info->skb = skb;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   643
map_skb:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   644
		buffer_info->dma = dma_map_single(&pdev->dev, skb->data,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   645
						  adapter->rx_buffer_len,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   646
						  DMA_FROM_DEVICE);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   647
		if (dma_mapping_error(&pdev->dev, buffer_info->dma)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   648
			dev_err(&pdev->dev, "Rx DMA map failed\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   649
			adapter->rx_dma_failed++;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   650
			break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   651
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   652
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   653
		rx_desc = E1000_RX_DESC_EXT(*rx_ring, i);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   654
		rx_desc->read.buffer_addr = cpu_to_le64(buffer_info->dma);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   655
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   656
		if (unlikely(!(i & (E1000_RX_BUFFER_WRITE - 1)))) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   657
			/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   658
			 * Force memory writes to complete before letting h/w
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   659
			 * know there are new descriptors to fetch.  (Only
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   660
			 * applicable for weak-ordered memory model archs,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   661
			 * such as IA-64).
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   662
			 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   663
			wmb();
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   664
			if (adapter->flags2 & FLAG2_PCIM2PCI_ARBITER_WA)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   665
				e1000e_update_rdt_wa(adapter, i);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   666
			else
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   667
				writel(i, adapter->hw.hw_addr + rx_ring->tail);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   668
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   669
		i++;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   670
		if (i == rx_ring->count)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   671
			i = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   672
		buffer_info = &rx_ring->buffer_info[i];
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   673
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   674
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   675
	rx_ring->next_to_use = i;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   676
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   677
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   678
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   679
 * e1000_alloc_rx_buffers_ps - Replace used receive buffers; packet split
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   680
 * @adapter: address of board private structure
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   681
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   682
static void e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   683
				      int cleaned_count, gfp_t gfp)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   684
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   685
	struct net_device *netdev = adapter->netdev;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   686
	struct pci_dev *pdev = adapter->pdev;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   687
	union e1000_rx_desc_packet_split *rx_desc;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   688
	struct e1000_ring *rx_ring = adapter->rx_ring;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   689
	struct e1000_buffer *buffer_info;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   690
	struct e1000_ps_page *ps_page;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   691
	struct sk_buff *skb;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   692
	unsigned int i, j;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   693
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   694
	i = rx_ring->next_to_use;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   695
	buffer_info = &rx_ring->buffer_info[i];
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   696
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   697
	while (cleaned_count--) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   698
		rx_desc = E1000_RX_DESC_PS(*rx_ring, i);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   699
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   700
		for (j = 0; j < PS_PAGE_BUFFERS; j++) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   701
			ps_page = &buffer_info->ps_pages[j];
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   702
			if (j >= adapter->rx_ps_pages) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   703
				/* all unused desc entries get hw null ptr */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   704
				rx_desc->read.buffer_addr[j + 1] =
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   705
				    ~cpu_to_le64(0);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   706
				continue;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   707
			}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   708
			if (!ps_page->page) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   709
				ps_page->page = alloc_page(gfp);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   710
				if (!ps_page->page) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   711
					adapter->alloc_rx_buff_failed++;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   712
					goto no_buffers;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   713
				}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   714
				ps_page->dma = dma_map_page(&pdev->dev,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   715
							    ps_page->page,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   716
							    0, PAGE_SIZE,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   717
							    DMA_FROM_DEVICE);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   718
				if (dma_mapping_error(&pdev->dev,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   719
						      ps_page->dma)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   720
					dev_err(&adapter->pdev->dev,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   721
						"Rx DMA page map failed\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   722
					adapter->rx_dma_failed++;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   723
					goto no_buffers;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   724
				}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   725
			}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   726
			/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   727
			 * Refresh the desc even if buffer_addrs
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   728
			 * didn't change because each write-back
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   729
			 * erases this info.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   730
			 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   731
			rx_desc->read.buffer_addr[j + 1] =
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   732
			    cpu_to_le64(ps_page->dma);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   733
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   734
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   735
		skb = __netdev_alloc_skb_ip_align(netdev,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   736
						  adapter->rx_ps_bsize0,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   737
						  gfp);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   738
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   739
		if (!skb) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   740
			adapter->alloc_rx_buff_failed++;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   741
			break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   742
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   743
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   744
		buffer_info->skb = skb;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   745
		buffer_info->dma = dma_map_single(&pdev->dev, skb->data,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   746
						  adapter->rx_ps_bsize0,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   747
						  DMA_FROM_DEVICE);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   748
		if (dma_mapping_error(&pdev->dev, buffer_info->dma)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   749
			dev_err(&pdev->dev, "Rx DMA map failed\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   750
			adapter->rx_dma_failed++;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   751
			/* cleanup skb */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   752
			dev_kfree_skb_any(skb);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   753
			buffer_info->skb = NULL;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   754
			break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   755
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   756
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   757
		rx_desc->read.buffer_addr[0] = cpu_to_le64(buffer_info->dma);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   758
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   759
		if (unlikely(!(i & (E1000_RX_BUFFER_WRITE - 1)))) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   760
			/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   761
			 * Force memory writes to complete before letting h/w
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   762
			 * know there are new descriptors to fetch.  (Only
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   763
			 * applicable for weak-ordered memory model archs,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   764
			 * such as IA-64).
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   765
			 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   766
			wmb();
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   767
			if (adapter->flags2 & FLAG2_PCIM2PCI_ARBITER_WA)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   768
				e1000e_update_rdt_wa(adapter, i << 1);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   769
			else
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   770
				writel(i << 1,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   771
				       adapter->hw.hw_addr + rx_ring->tail);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   772
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   773
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   774
		i++;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   775
		if (i == rx_ring->count)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   776
			i = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   777
		buffer_info = &rx_ring->buffer_info[i];
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   778
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   779
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   780
no_buffers:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   781
	rx_ring->next_to_use = i;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   782
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   783
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   784
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   785
 * e1000_alloc_jumbo_rx_buffers - Replace used jumbo receive buffers
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   786
 * @adapter: address of board private structure
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   787
 * @cleaned_count: number of buffers to allocate this pass
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   788
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   789
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   790
static void e1000_alloc_jumbo_rx_buffers(struct e1000_adapter *adapter,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   791
					 int cleaned_count, gfp_t gfp)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   792
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   793
	struct net_device *netdev = adapter->netdev;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   794
	struct pci_dev *pdev = adapter->pdev;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   795
	union e1000_rx_desc_extended *rx_desc;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   796
	struct e1000_ring *rx_ring = adapter->rx_ring;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   797
	struct e1000_buffer *buffer_info;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   798
	struct sk_buff *skb;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   799
	unsigned int i;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   800
	unsigned int bufsz = 256 - 16 /* for skb_reserve */;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   801
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   802
	i = rx_ring->next_to_use;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   803
	buffer_info = &rx_ring->buffer_info[i];
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   804
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   805
	while (cleaned_count--) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   806
		skb = buffer_info->skb;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   807
		if (skb) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   808
			skb_trim(skb, 0);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   809
			goto check_page;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   810
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   811
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   812
		skb = __netdev_alloc_skb_ip_align(netdev, bufsz, gfp);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   813
		if (unlikely(!skb)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   814
			/* Better luck next round */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   815
			adapter->alloc_rx_buff_failed++;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   816
			break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   817
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   818
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   819
		buffer_info->skb = skb;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   820
check_page:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   821
		/* allocate a new page if necessary */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   822
		if (!buffer_info->page) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   823
			buffer_info->page = alloc_page(gfp);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   824
			if (unlikely(!buffer_info->page)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   825
				adapter->alloc_rx_buff_failed++;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   826
				break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   827
			}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   828
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   829
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   830
		if (!buffer_info->dma)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   831
			buffer_info->dma = dma_map_page(&pdev->dev,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   832
			                                buffer_info->page, 0,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   833
			                                PAGE_SIZE,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   834
							DMA_FROM_DEVICE);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   835
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   836
		rx_desc = E1000_RX_DESC_EXT(*rx_ring, i);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   837
		rx_desc->read.buffer_addr = cpu_to_le64(buffer_info->dma);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   838
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   839
		if (unlikely(++i == rx_ring->count))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   840
			i = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   841
		buffer_info = &rx_ring->buffer_info[i];
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   842
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   843
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   844
	if (likely(rx_ring->next_to_use != i)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   845
		rx_ring->next_to_use = i;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   846
		if (unlikely(i-- == 0))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   847
			i = (rx_ring->count - 1);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   848
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   849
		/* Force memory writes to complete before letting h/w
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   850
		 * know there are new descriptors to fetch.  (Only
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   851
		 * applicable for weak-ordered memory model archs,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   852
		 * such as IA-64). */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   853
		wmb();
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   854
		if (adapter->flags2 & FLAG2_PCIM2PCI_ARBITER_WA)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   855
			e1000e_update_rdt_wa(adapter, i);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   856
		else
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   857
			writel(i, adapter->hw.hw_addr + rx_ring->tail);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   858
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   859
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   860
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   861
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   862
 * e1000_clean_rx_irq - Send received data up the network stack; legacy
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   863
 * @adapter: board private structure
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   864
 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   865
 * the return value indicates whether actual cleaning was done, there
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   866
 * is no guarantee that everything was cleaned
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   867
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   868
static bool e1000_clean_rx_irq(struct e1000_adapter *adapter,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   869
			       int *work_done, int work_to_do)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   870
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   871
	struct net_device *netdev = adapter->netdev;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   872
	struct pci_dev *pdev = adapter->pdev;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   873
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   874
	struct e1000_ring *rx_ring = adapter->rx_ring;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   875
	union e1000_rx_desc_extended *rx_desc, *next_rxd;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   876
	struct e1000_buffer *buffer_info, *next_buffer;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   877
	u32 length, staterr;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   878
	unsigned int i;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   879
	int cleaned_count = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   880
	bool cleaned = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   881
	unsigned int total_rx_bytes = 0, total_rx_packets = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   882
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   883
	i = rx_ring->next_to_clean;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   884
	rx_desc = E1000_RX_DESC_EXT(*rx_ring, i);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   885
	staterr = le32_to_cpu(rx_desc->wb.upper.status_error);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   886
	buffer_info = &rx_ring->buffer_info[i];
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   887
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   888
	while (staterr & E1000_RXD_STAT_DD) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   889
		struct sk_buff *skb;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   890
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   891
		if (*work_done >= work_to_do)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   892
			break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   893
		(*work_done)++;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   894
		rmb();	/* read descriptor and rx_buffer_info after status DD */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   895
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   896
		skb = buffer_info->skb;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   897
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   898
		if (!adapter->ecdev)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   899
			buffer_info->skb = NULL;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   900
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   901
		prefetch(skb->data - NET_IP_ALIGN);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   902
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   903
		i++;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   904
		if (i == rx_ring->count)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   905
			i = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   906
		next_rxd = E1000_RX_DESC_EXT(*rx_ring, i);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   907
		prefetch(next_rxd);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   908
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   909
		next_buffer = &rx_ring->buffer_info[i];
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   910
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   911
		cleaned = 1;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   912
		cleaned_count++;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   913
		dma_unmap_single(&pdev->dev,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   914
				 buffer_info->dma,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   915
				 adapter->rx_buffer_len,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   916
				 DMA_FROM_DEVICE);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   917
		buffer_info->dma = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   918
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   919
		length = le16_to_cpu(rx_desc->wb.upper.length);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   920
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   921
		/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   922
		 * !EOP means multiple descriptors were used to store a single
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   923
		 * packet, if that's the case we need to toss it.  In fact, we
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   924
		 * need to toss every packet with the EOP bit clear and the
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   925
		 * next frame that _does_ have the EOP bit set, as it is by
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   926
		 * definition only a frame fragment
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   927
		 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   928
		if (unlikely(!(staterr & E1000_RXD_STAT_EOP)))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   929
			adapter->flags2 |= FLAG2_IS_DISCARDING;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   930
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   931
		if (adapter->flags2 & FLAG2_IS_DISCARDING) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   932
			/* All receives must fit into a single buffer */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   933
			e_dbg("Receive packet consumed multiple buffers\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   934
			/* recycle */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   935
			buffer_info->skb = skb;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   936
			if (staterr & E1000_RXD_STAT_EOP)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   937
				adapter->flags2 &= ~FLAG2_IS_DISCARDING;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   938
			goto next_desc;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   939
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   940
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   941
		if (!adapter->ecdev && (staterr & E1000_RXDEXT_ERR_FRAME_ERR_MASK)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   942
			/* recycle */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   943
			buffer_info->skb = skb;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   944
			goto next_desc;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   945
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   946
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   947
		/* adjust length to remove Ethernet CRC */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   948
		if (!(adapter->flags2 & FLAG2_CRC_STRIPPING))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   949
			length -= 4;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   950
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   951
		total_rx_bytes += length;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   952
		total_rx_packets++;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   953
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   954
		/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   955
		 * code added for copybreak, this should improve
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   956
		 * performance for small packets with large amounts
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   957
		 * of reassembly being done in the stack
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   958
		 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   959
		if (!adapter->ecdev && length < copybreak) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   960
			struct sk_buff *new_skb =
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   961
			    netdev_alloc_skb_ip_align(netdev, length);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   962
			if (new_skb) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   963
				skb_copy_to_linear_data_offset(new_skb,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   964
							       -NET_IP_ALIGN,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   965
							       (skb->data -
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   966
								NET_IP_ALIGN),
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   967
							       (length +
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   968
								NET_IP_ALIGN));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   969
				/* save the skb in buffer_info as good */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   970
				buffer_info->skb = skb;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   971
				skb = new_skb;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   972
			}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   973
			/* else just continue with the old one */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   974
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   975
		/* end copybreak code */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   976
		skb_put(skb, length);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   977
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   978
		/* Receive Checksum Offload */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   979
		e1000_rx_checksum(adapter, staterr,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   980
				  le16_to_cpu(rx_desc->wb.lower.hi_dword.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   981
					      csum_ip.csum), skb);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   982
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   983
		if (adapter->ecdev) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   984
			ecdev_receive(adapter->ecdev, skb->data, length);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   985
			adapter->ec_watchdog_jiffies = jiffies;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   986
		} else {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   987
		    e1000_receive_skb(adapter, netdev, skb, staterr,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   988
				      rx_desc->wb.upper.vlan);
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
   989
		}
2406
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   990
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   991
next_desc:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   992
		rx_desc->wb.upper.status_error &= cpu_to_le32(~0xFF);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   993
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   994
		/* return some buffers to hardware, one at a time is too slow */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   995
		if (cleaned_count >= E1000_RX_BUFFER_WRITE) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   996
			adapter->alloc_rx_buf(adapter, cleaned_count,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   997
					      GFP_ATOMIC);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   998
			cleaned_count = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   999
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1000
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1001
		/* use prefetched values */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1002
		rx_desc = next_rxd;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1003
		buffer_info = next_buffer;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1004
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1005
		staterr = le32_to_cpu(rx_desc->wb.upper.status_error);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1006
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1007
	rx_ring->next_to_clean = i;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1008
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1009
	cleaned_count = e1000_desc_unused(rx_ring);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1010
	if (cleaned_count)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1011
		adapter->alloc_rx_buf(adapter, cleaned_count, GFP_ATOMIC);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1012
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1013
	adapter->total_rx_bytes += total_rx_bytes;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1014
	adapter->total_rx_packets += total_rx_packets;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1015
	return cleaned;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1016
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1017
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1018
static void e1000_put_txbuf(struct e1000_adapter *adapter,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1019
			     struct e1000_buffer *buffer_info)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1020
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1021
	if (adapter->ecdev)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1022
		return;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1023
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1024
	if (buffer_info->dma) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1025
		if (buffer_info->mapped_as_page)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1026
			dma_unmap_page(&adapter->pdev->dev, buffer_info->dma,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1027
				       buffer_info->length, DMA_TO_DEVICE);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1028
		else
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1029
			dma_unmap_single(&adapter->pdev->dev, buffer_info->dma,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1030
					 buffer_info->length, DMA_TO_DEVICE);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1031
		buffer_info->dma = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1032
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1033
	if (buffer_info->skb) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1034
		dev_kfree_skb_any(buffer_info->skb);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1035
		buffer_info->skb = NULL;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1036
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1037
	buffer_info->time_stamp = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1038
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1039
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1040
static void e1000_print_hw_hang(struct work_struct *work)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1041
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1042
	struct e1000_adapter *adapter = container_of(work,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1043
	                                             struct e1000_adapter,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1044
	                                             print_hang_task);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1045
	struct net_device *netdev = adapter->netdev;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1046
	struct e1000_ring *tx_ring = adapter->tx_ring;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1047
	unsigned int i = tx_ring->next_to_clean;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1048
	unsigned int eop = tx_ring->buffer_info[i].next_to_watch;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1049
	struct e1000_tx_desc *eop_desc = E1000_TX_DESC(*tx_ring, eop);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1050
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1051
	u16 phy_status, phy_1000t_status, phy_ext_status;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1052
	u16 pci_status;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1053
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1054
	if (test_bit(__E1000_DOWN, &adapter->state))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1055
		return;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1056
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1057
	if (!adapter->tx_hang_recheck &&
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1058
	    (adapter->flags2 & FLAG2_DMA_BURST)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1059
		/* May be block on write-back, flush and detect again
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1060
		 * flush pending descriptor writebacks to memory
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1061
		 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1062
		ew32(TIDV, adapter->tx_int_delay | E1000_TIDV_FPD);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1063
		/* execute the writes immediately */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1064
		e1e_flush();
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1065
		adapter->tx_hang_recheck = true;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1066
		return;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1067
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1068
	/* Real hang detected */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1069
	adapter->tx_hang_recheck = false;
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  1070
	if (!adapter->ecdev) {
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  1071
		netif_stop_queue(netdev);
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  1072
	}
2406
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1073
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1074
	e1e_rphy(hw, PHY_STATUS, &phy_status);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1075
	e1e_rphy(hw, PHY_1000T_STATUS, &phy_1000t_status);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1076
	e1e_rphy(hw, PHY_EXT_STATUS, &phy_ext_status);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1077
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1078
	pci_read_config_word(adapter->pdev, PCI_STATUS, &pci_status);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1079
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1080
	/* detected Hardware unit hang */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1081
	e_err("Detected Hardware Unit Hang:\n"
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1082
	      "  TDH                  <%x>\n"
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1083
	      "  TDT                  <%x>\n"
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1084
	      "  next_to_use          <%x>\n"
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1085
	      "  next_to_clean        <%x>\n"
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1086
	      "buffer_info[next_to_clean]:\n"
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1087
	      "  time_stamp           <%lx>\n"
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1088
	      "  next_to_watch        <%x>\n"
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1089
	      "  jiffies              <%lx>\n"
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1090
	      "  next_to_watch.status <%x>\n"
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1091
	      "MAC Status             <%x>\n"
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1092
	      "PHY Status             <%x>\n"
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1093
	      "PHY 1000BASE-T Status  <%x>\n"
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1094
	      "PHY Extended Status    <%x>\n"
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1095
	      "PCI Status             <%x>\n",
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1096
	      readl(adapter->hw.hw_addr + tx_ring->head),
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1097
	      readl(adapter->hw.hw_addr + tx_ring->tail),
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1098
	      tx_ring->next_to_use,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1099
	      tx_ring->next_to_clean,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1100
	      tx_ring->buffer_info[eop].time_stamp,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1101
	      eop,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1102
	      jiffies,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1103
	      eop_desc->upper.fields.status,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1104
	      er32(STATUS),
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1105
	      phy_status,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1106
	      phy_1000t_status,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1107
	      phy_ext_status,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1108
	      pci_status);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1109
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1110
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1111
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1112
 * e1000_clean_tx_irq - Reclaim resources after transmit completes
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1113
 * @adapter: board private structure
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1114
 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1115
 * the return value indicates whether actual cleaning was done, there
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1116
 * is no guarantee that everything was cleaned
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1117
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1118
static bool e1000_clean_tx_irq(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1119
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1120
	struct net_device *netdev = adapter->netdev;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1121
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1122
	struct e1000_ring *tx_ring = adapter->tx_ring;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1123
	struct e1000_tx_desc *tx_desc, *eop_desc;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1124
	struct e1000_buffer *buffer_info;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1125
	unsigned int i, eop;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1126
	unsigned int count = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1127
	unsigned int total_tx_bytes = 0, total_tx_packets = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1128
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1129
	i = tx_ring->next_to_clean;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1130
	eop = tx_ring->buffer_info[i].next_to_watch;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1131
	eop_desc = E1000_TX_DESC(*tx_ring, eop);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1132
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1133
	while ((eop_desc->upper.data & cpu_to_le32(E1000_TXD_STAT_DD)) &&
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1134
	       (count < tx_ring->count)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1135
		bool cleaned = false;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1136
		rmb(); /* read buffer_info after eop_desc */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1137
		for (; !cleaned; count++) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1138
			tx_desc = E1000_TX_DESC(*tx_ring, i);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1139
			buffer_info = &tx_ring->buffer_info[i];
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1140
			cleaned = (i == eop);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1141
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1142
			if (cleaned) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1143
				total_tx_packets += buffer_info->segs;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1144
				total_tx_bytes += buffer_info->bytecount;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1145
			}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1146
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1147
			e1000_put_txbuf(adapter, buffer_info);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1148
			tx_desc->upper.data = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1149
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1150
			i++;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1151
			if (i == tx_ring->count)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1152
				i = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1153
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1154
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1155
		if (i == tx_ring->next_to_use)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1156
			break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1157
		eop = tx_ring->buffer_info[i].next_to_watch;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1158
		eop_desc = E1000_TX_DESC(*tx_ring, eop);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1159
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1160
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1161
	tx_ring->next_to_clean = i;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1162
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1163
#define TX_WAKE_THRESHOLD 32
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1164
	if (!adapter->ecdev && count && netif_carrier_ok(netdev) &&
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1165
	    e1000_desc_unused(tx_ring) >= TX_WAKE_THRESHOLD) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1166
		/* Make sure that anybody stopping the queue after this
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1167
		 * sees the new next_to_clean.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1168
		 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1169
		smp_mb();
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1170
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1171
		if (netif_queue_stopped(netdev) &&
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1172
		    !(test_bit(__E1000_DOWN, &adapter->state))) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1173
			netif_wake_queue(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1174
			++adapter->restart_queue;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1175
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1176
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1177
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1178
	if (!adapter->ecdev && adapter->detect_tx_hung) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1179
		/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1180
		 * Detect a transmit hang in hardware, this serializes the
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1181
		 * check with the clearing of time_stamp and movement of i
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1182
		 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1183
		adapter->detect_tx_hung = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1184
		if (tx_ring->buffer_info[i].time_stamp &&
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1185
		    time_after(jiffies, tx_ring->buffer_info[i].time_stamp
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1186
			       + (adapter->tx_timeout_factor * HZ)) &&
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1187
		    !(er32(STATUS) & E1000_STATUS_TXOFF))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1188
			schedule_work(&adapter->print_hang_task);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1189
		else
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1190
			adapter->tx_hang_recheck = false;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1191
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1192
	adapter->total_tx_bytes += total_tx_bytes;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1193
	adapter->total_tx_packets += total_tx_packets;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1194
	return count < tx_ring->count;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1195
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1196
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1197
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1198
 * e1000_clean_rx_irq_ps - Send received data up the network stack; packet split
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1199
 * @adapter: board private structure
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1200
 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1201
 * the return value indicates whether actual cleaning was done, there
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1202
 * is no guarantee that everything was cleaned
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1203
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1204
static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1205
				  int *work_done, int work_to_do)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1206
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1207
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1208
	union e1000_rx_desc_packet_split *rx_desc, *next_rxd;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1209
	struct net_device *netdev = adapter->netdev;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1210
	struct pci_dev *pdev = adapter->pdev;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1211
	struct e1000_ring *rx_ring = adapter->rx_ring;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1212
	struct e1000_buffer *buffer_info, *next_buffer;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1213
	struct e1000_ps_page *ps_page;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1214
	struct sk_buff *skb;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1215
	unsigned int i, j;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1216
	u32 length, staterr;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1217
	int cleaned_count = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1218
	bool cleaned = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1219
	unsigned int total_rx_bytes = 0, total_rx_packets = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1220
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1221
	i = rx_ring->next_to_clean;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1222
	rx_desc = E1000_RX_DESC_PS(*rx_ring, i);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1223
	staterr = le32_to_cpu(rx_desc->wb.middle.status_error);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1224
	buffer_info = &rx_ring->buffer_info[i];
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1225
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1226
	while (staterr & E1000_RXD_STAT_DD) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1227
		if (*work_done >= work_to_do)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1228
			break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1229
		(*work_done)++;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1230
		skb = buffer_info->skb;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1231
		rmb();	/* read descriptor and rx_buffer_info after status DD */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1232
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1233
		/* in the packet split case this is header only */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1234
		prefetch(skb->data - NET_IP_ALIGN);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1235
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1236
		i++;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1237
		if (i == rx_ring->count)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1238
			i = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1239
		next_rxd = E1000_RX_DESC_PS(*rx_ring, i);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1240
		prefetch(next_rxd);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1241
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1242
		next_buffer = &rx_ring->buffer_info[i];
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1243
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1244
		cleaned = 1;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1245
		cleaned_count++;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1246
		dma_unmap_single(&pdev->dev, buffer_info->dma,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1247
				 adapter->rx_ps_bsize0, DMA_FROM_DEVICE);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1248
		buffer_info->dma = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1249
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1250
		/* see !EOP comment in other Rx routine */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1251
		if (!(staterr & E1000_RXD_STAT_EOP))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1252
			adapter->flags2 |= FLAG2_IS_DISCARDING;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1253
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1254
		if (adapter->flags2 & FLAG2_IS_DISCARDING) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1255
			e_dbg("Packet Split buffers didn't pick up the full "
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1256
			      "packet\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1257
			if (!adapter->ecdev) dev_kfree_skb_irq(skb);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1258
			if (staterr & E1000_RXD_STAT_EOP)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1259
				adapter->flags2 &= ~FLAG2_IS_DISCARDING;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1260
			goto next_desc;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1261
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1262
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1263
		if (staterr & E1000_RXDEXT_ERR_FRAME_ERR_MASK) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1264
			if (!adapter->ecdev)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1265
				dev_kfree_skb_irq(skb);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1266
			goto next_desc;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1267
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1268
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1269
		length = le16_to_cpu(rx_desc->wb.middle.length0);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1270
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1271
		if (!length) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1272
			e_dbg("Last part of the packet spanning multiple "
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1273
			      "descriptors\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1274
			if (!adapter->ecdev)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1275
				dev_kfree_skb_irq(skb);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1276
			goto next_desc;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1277
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1278
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1279
		/* Good Receive */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1280
		skb_put(skb, length);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1281
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1282
		{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1283
		/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1284
		 * this looks ugly, but it seems compiler issues make it
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1285
		 * more efficient than reusing j
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1286
		 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1287
		int l1 = le16_to_cpu(rx_desc->wb.upper.length[0]);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1288
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1289
		/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1290
		 * page alloc/put takes too long and effects small packet
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1291
		 * throughput, so unsplit small packets and save the alloc/put
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1292
		 * only valid in softirq (napi) context to call kmap_*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1293
		 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1294
		if (l1 && (l1 <= copybreak) &&
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1295
		    ((length + l1) <= adapter->rx_ps_bsize0)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1296
			u8 *vaddr;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1297
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1298
			ps_page = &buffer_info->ps_pages[0];
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1299
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1300
			/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1301
			 * there is no documentation about how to call
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1302
			 * kmap_atomic, so we can't hold the mapping
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1303
			 * very long
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1304
			 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1305
			dma_sync_single_for_cpu(&pdev->dev, ps_page->dma,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1306
						PAGE_SIZE, DMA_FROM_DEVICE);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1307
			vaddr = kmap_atomic(ps_page->page, KM_SKB_DATA_SOFTIRQ);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1308
			memcpy(skb_tail_pointer(skb), vaddr, l1);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1309
			kunmap_atomic(vaddr, KM_SKB_DATA_SOFTIRQ);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1310
			dma_sync_single_for_device(&pdev->dev, ps_page->dma,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1311
						   PAGE_SIZE, DMA_FROM_DEVICE);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1312
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1313
			/* remove the CRC */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1314
			if (!(adapter->flags2 & FLAG2_CRC_STRIPPING))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1315
				l1 -= 4;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1316
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1317
			skb_put(skb, l1);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1318
			goto copydone;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1319
		} /* if */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1320
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1321
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1322
		for (j = 0; j < PS_PAGE_BUFFERS; j++) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1323
			length = le16_to_cpu(rx_desc->wb.upper.length[j]);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1324
			if (!length)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1325
				break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1326
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1327
			ps_page = &buffer_info->ps_pages[j];
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1328
			dma_unmap_page(&pdev->dev, ps_page->dma, PAGE_SIZE,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1329
				       DMA_FROM_DEVICE);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1330
			ps_page->dma = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1331
			skb_fill_page_desc(skb, j, ps_page->page, 0, length);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1332
			ps_page->page = NULL;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1333
			skb->len += length;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1334
			skb->data_len += length;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1335
			skb->truesize += PAGE_SIZE;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1336
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1337
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1338
		/* strip the ethernet crc, problem is we're using pages now so
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1339
		 * this whole operation can get a little cpu intensive
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1340
		 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1341
		if (!(adapter->flags2 & FLAG2_CRC_STRIPPING))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1342
			pskb_trim(skb, skb->len - 4);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1343
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1344
copydone:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1345
		total_rx_bytes += skb->len;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1346
		total_rx_packets++;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1347
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1348
		e1000_rx_checksum(adapter, staterr, le16_to_cpu(
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1349
			rx_desc->wb.lower.hi_dword.csum_ip.csum), skb);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1350
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1351
		if (rx_desc->wb.upper.header_status &
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1352
			   cpu_to_le16(E1000_RXDPS_HDRSTAT_HDRSP))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1353
			adapter->rx_hdr_split++;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1354
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1355
		if (adapter->ecdev) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1356
			ecdev_receive(adapter->ecdev, skb->data, length);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1357
			adapter->ec_watchdog_jiffies = jiffies;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1358
		} else {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1359
			e1000_receive_skb(adapter, netdev, skb,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1360
					  staterr, rx_desc->wb.middle.vlan);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1361
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1362
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1363
next_desc:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1364
		rx_desc->wb.middle.status_error &= cpu_to_le32(~0xFF);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1365
		if (!adapter->ecdev) buffer_info->skb = NULL;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1366
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1367
		/* return some buffers to hardware, one at a time is too slow */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1368
		if (cleaned_count >= E1000_RX_BUFFER_WRITE) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1369
			adapter->alloc_rx_buf(adapter, cleaned_count,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1370
					      GFP_ATOMIC);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1371
			cleaned_count = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1372
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1373
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1374
		/* use prefetched values */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1375
		rx_desc = next_rxd;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1376
		buffer_info = next_buffer;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1377
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1378
		staterr = le32_to_cpu(rx_desc->wb.middle.status_error);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1379
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1380
	rx_ring->next_to_clean = i;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1381
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1382
	cleaned_count = e1000_desc_unused(rx_ring);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1383
	if (cleaned_count)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1384
		adapter->alloc_rx_buf(adapter, cleaned_count, GFP_ATOMIC);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1385
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1386
	adapter->total_rx_bytes += total_rx_bytes;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1387
	adapter->total_rx_packets += total_rx_packets;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1388
	return cleaned;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1389
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1390
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1391
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1392
 * e1000_consume_page - helper function
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1393
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1394
static void e1000_consume_page(struct e1000_buffer *bi, struct sk_buff *skb,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1395
                               u16 length)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1396
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1397
	bi->page = NULL;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1398
	skb->len += length;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1399
	skb->data_len += length;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1400
	skb->truesize += PAGE_SIZE;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1401
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1402
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1403
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1404
 * e1000_clean_jumbo_rx_irq - Send received data up the network stack; legacy
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1405
 * @adapter: board private structure
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1406
 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1407
 * the return value indicates whether actual cleaning was done, there
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1408
 * is no guarantee that everything was cleaned
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1409
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1410
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1411
static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1412
                                     int *work_done, int work_to_do)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1413
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1414
	struct net_device *netdev = adapter->netdev;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1415
	struct pci_dev *pdev = adapter->pdev;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1416
	struct e1000_ring *rx_ring = adapter->rx_ring;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1417
	union e1000_rx_desc_extended *rx_desc, *next_rxd;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1418
	struct e1000_buffer *buffer_info, *next_buffer;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1419
	u32 length, staterr;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1420
	unsigned int i;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1421
	int cleaned_count = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1422
	bool cleaned = false;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1423
	unsigned int total_rx_bytes=0, total_rx_packets=0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1424
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1425
	i = rx_ring->next_to_clean;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1426
	rx_desc = E1000_RX_DESC_EXT(*rx_ring, i);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1427
	staterr = le32_to_cpu(rx_desc->wb.upper.status_error);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1428
	buffer_info = &rx_ring->buffer_info[i];
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1429
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1430
	while (staterr & E1000_RXD_STAT_DD) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1431
		struct sk_buff *skb;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1432
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1433
		if (*work_done >= work_to_do)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1434
			break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1435
		(*work_done)++;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1436
		rmb();	/* read descriptor and rx_buffer_info after status DD */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1437
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1438
		skb = buffer_info->skb;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1439
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1440
		if (!adapter->ecdev)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1441
			buffer_info->skb = NULL;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1442
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1443
		++i;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1444
		if (i == rx_ring->count)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1445
			i = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1446
		next_rxd = E1000_RX_DESC_EXT(*rx_ring, i);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1447
		prefetch(next_rxd);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1448
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1449
		next_buffer = &rx_ring->buffer_info[i];
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1450
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1451
		cleaned = true;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1452
		cleaned_count++;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1453
		dma_unmap_page(&pdev->dev, buffer_info->dma, PAGE_SIZE,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1454
			       DMA_FROM_DEVICE);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1455
		buffer_info->dma = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1456
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1457
		length = le16_to_cpu(rx_desc->wb.upper.length);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1458
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1459
		/* errors is only valid for DD + EOP descriptors */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1460
		if (!adapter->ecdev && (unlikely((staterr & E1000_RXD_STAT_EOP) &&
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1461
			     (staterr & E1000_RXDEXT_ERR_FRAME_ERR_MASK)))) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1462
			/* recycle both page and skb */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1463
			buffer_info->skb = skb;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1464
			/* an error means any chain goes out the window too */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1465
			if (rx_ring->rx_skb_top)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1466
				dev_kfree_skb_irq(rx_ring->rx_skb_top);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1467
			rx_ring->rx_skb_top = NULL;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1468
			goto next_desc;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1469
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1470
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1471
#define rxtop (rx_ring->rx_skb_top)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1472
		if (!(staterr & E1000_RXD_STAT_EOP)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1473
			/* this descriptor is only the beginning (or middle) */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1474
			if (!rxtop) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1475
				/* this is the beginning of a chain */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1476
				rxtop = skb;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1477
				skb_fill_page_desc(rxtop, 0, buffer_info->page,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1478
				                   0, length);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1479
			} else {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1480
				/* this is the middle of a chain */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1481
				skb_fill_page_desc(rxtop,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1482
				    skb_shinfo(rxtop)->nr_frags,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1483
				    buffer_info->page, 0, length);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1484
				/* re-use the skb, only consumed the page */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1485
				buffer_info->skb = skb;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1486
			}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1487
			e1000_consume_page(buffer_info, rxtop, length);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1488
			goto next_desc;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1489
		} else {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1490
			if (rxtop) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1491
				/* end of the chain */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1492
				skb_fill_page_desc(rxtop,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1493
				    skb_shinfo(rxtop)->nr_frags,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1494
				    buffer_info->page, 0, length);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1495
				/* re-use the current skb, we only consumed the
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1496
				 * page */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1497
				buffer_info->skb = skb;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1498
				skb = rxtop;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1499
				rxtop = NULL;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1500
				e1000_consume_page(buffer_info, skb, length);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1501
			} else {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1502
				/* no chain, got EOP, this buf is the packet
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1503
				 * copybreak to save the put_page/alloc_page */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1504
				if (length <= copybreak &&
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1505
				    skb_tailroom(skb) >= length) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1506
					u8 *vaddr;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1507
					vaddr = kmap_atomic(buffer_info->page,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1508
					                   KM_SKB_DATA_SOFTIRQ);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1509
					memcpy(skb_tail_pointer(skb), vaddr,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1510
					       length);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1511
					kunmap_atomic(vaddr,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1512
					              KM_SKB_DATA_SOFTIRQ);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1513
					/* re-use the page, so don't erase
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1514
					 * buffer_info->page */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1515
					skb_put(skb, length);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1516
				} else {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1517
					skb_fill_page_desc(skb, 0,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1518
					                   buffer_info->page, 0,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1519
				                           length);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1520
					e1000_consume_page(buffer_info, skb,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1521
					                   length);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1522
				}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1523
			}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1524
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1525
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1526
		/* Receive Checksum Offload XXX recompute due to CRC strip? */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1527
		e1000_rx_checksum(adapter, staterr,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1528
				  le16_to_cpu(rx_desc->wb.lower.hi_dword.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1529
					      csum_ip.csum), skb);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1530
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1531
		/* probably a little skewed due to removing CRC */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1532
		total_rx_bytes += skb->len;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1533
		total_rx_packets++;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1534
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1535
		/* eth type trans needs skb->data to point to something */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1536
		if (!adapter->ecdev && !pskb_may_pull(skb, ETH_HLEN)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1537
			e_err("pskb_may_pull failed.\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1538
			dev_kfree_skb_irq(skb);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1539
			goto next_desc;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1540
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1541
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1542
		if (adapter->ecdev) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1543
			ecdev_receive(adapter->ecdev, skb->data, length);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1544
			adapter->ec_watchdog_jiffies = jiffies;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1545
		} else {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1546
			e1000_receive_skb(adapter, netdev, skb, staterr,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1547
					  rx_desc->wb.upper.vlan);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1548
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1549
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1550
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1551
next_desc:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1552
		rx_desc->wb.upper.status_error &= cpu_to_le32(~0xFF);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1553
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1554
		/* return some buffers to hardware, one at a time is too slow */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1555
		if (unlikely(cleaned_count >= E1000_RX_BUFFER_WRITE)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1556
			adapter->alloc_rx_buf(adapter, cleaned_count,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1557
					      GFP_ATOMIC);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1558
			cleaned_count = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1559
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1560
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1561
		/* use prefetched values */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1562
		rx_desc = next_rxd;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1563
		buffer_info = next_buffer;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1564
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1565
		staterr = le32_to_cpu(rx_desc->wb.upper.status_error);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1566
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1567
	rx_ring->next_to_clean = i;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1568
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1569
	cleaned_count = e1000_desc_unused(rx_ring);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1570
	if (cleaned_count)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1571
		adapter->alloc_rx_buf(adapter, cleaned_count, GFP_ATOMIC);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1572
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1573
	adapter->total_rx_bytes += total_rx_bytes;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1574
	adapter->total_rx_packets += total_rx_packets;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1575
	return cleaned;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1576
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1577
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1578
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1579
 * e1000_clean_rx_ring - Free Rx Buffers per Queue
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1580
 * @adapter: board private structure
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1581
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1582
static void e1000_clean_rx_ring(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1583
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1584
	struct e1000_ring *rx_ring = adapter->rx_ring;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1585
	struct e1000_buffer *buffer_info;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1586
	struct e1000_ps_page *ps_page;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1587
	struct pci_dev *pdev = adapter->pdev;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1588
	unsigned int i, j;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1589
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1590
	/* Free all the Rx ring sk_buffs */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1591
	for (i = 0; i < rx_ring->count; i++) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1592
		buffer_info = &rx_ring->buffer_info[i];
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1593
		if (buffer_info->dma) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1594
			if (adapter->clean_rx == e1000_clean_rx_irq)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1595
				dma_unmap_single(&pdev->dev, buffer_info->dma,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1596
						 adapter->rx_buffer_len,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1597
						 DMA_FROM_DEVICE);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1598
			else if (adapter->clean_rx == e1000_clean_jumbo_rx_irq)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1599
				dma_unmap_page(&pdev->dev, buffer_info->dma,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1600
				               PAGE_SIZE,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1601
					       DMA_FROM_DEVICE);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1602
			else if (adapter->clean_rx == e1000_clean_rx_irq_ps)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1603
				dma_unmap_single(&pdev->dev, buffer_info->dma,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1604
						 adapter->rx_ps_bsize0,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1605
						 DMA_FROM_DEVICE);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1606
			buffer_info->dma = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1607
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1608
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1609
		if (buffer_info->page) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1610
			put_page(buffer_info->page);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1611
			buffer_info->page = NULL;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1612
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1613
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1614
		if (buffer_info->skb) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1615
			dev_kfree_skb(buffer_info->skb);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1616
			buffer_info->skb = NULL;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1617
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1618
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1619
		for (j = 0; j < PS_PAGE_BUFFERS; j++) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1620
			ps_page = &buffer_info->ps_pages[j];
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1621
			if (!ps_page->page)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1622
				break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1623
			dma_unmap_page(&pdev->dev, ps_page->dma, PAGE_SIZE,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1624
				       DMA_FROM_DEVICE);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1625
			ps_page->dma = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1626
			put_page(ps_page->page);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1627
			ps_page->page = NULL;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1628
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1629
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1630
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1631
	/* there also may be some cached data from a chained receive */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1632
	if (rx_ring->rx_skb_top) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1633
		dev_kfree_skb(rx_ring->rx_skb_top);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1634
		rx_ring->rx_skb_top = NULL;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1635
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1636
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1637
	/* Zero out the descriptor ring */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1638
	memset(rx_ring->desc, 0, rx_ring->size);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1639
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1640
	rx_ring->next_to_clean = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1641
	rx_ring->next_to_use = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1642
	adapter->flags2 &= ~FLAG2_IS_DISCARDING;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1643
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1644
	writel(0, adapter->hw.hw_addr + rx_ring->head);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1645
	writel(0, adapter->hw.hw_addr + rx_ring->tail);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1646
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1647
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1648
static void e1000e_downshift_workaround(struct work_struct *work)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1649
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1650
	struct e1000_adapter *adapter = container_of(work,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1651
					struct e1000_adapter, downshift_task);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1652
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1653
	if (test_bit(__E1000_DOWN, &adapter->state))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1654
		return;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1655
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1656
	e1000e_gig_downshift_workaround_ich8lan(&adapter->hw);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1657
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1658
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1659
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1660
 * e1000_intr_msi - Interrupt Handler
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1661
 * @irq: interrupt number
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1662
 * @data: pointer to a network interface device structure
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1663
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1664
static irqreturn_t e1000_intr_msi(int irq, void *data)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1665
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1666
	struct net_device *netdev = data;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1667
	struct e1000_adapter *adapter = netdev_priv(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1668
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1669
	u32 icr = er32(ICR);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1670
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  1671
	if (adapter->ecdev) {
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  1672
		int ec_work_done = 0;
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  1673
		adapter->clean_rx(adapter, &ec_work_done, 100);
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  1674
		e1000_clean_tx_irq(adapter);
2406
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1675
		return IRQ_HANDLED;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1676
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1677
	/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1678
	 * read ICR disables interrupts using IAM
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1679
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1680
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1681
	if (icr & E1000_ICR_LSC) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1682
		hw->mac.get_link_status = 1;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1683
		/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1684
		 * ICH8 workaround-- Call gig speed drop workaround on cable
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1685
		 * disconnect (LSC) before accessing any PHY registers
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1686
		 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1687
		if ((adapter->flags & FLAG_LSC_GIG_SPEED_DROP) &&
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1688
		    (!(er32(STATUS) & E1000_STATUS_LU)))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1689
			schedule_work(&adapter->downshift_task);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1690
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1691
		/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1692
		 * 80003ES2LAN workaround-- For packet buffer work-around on
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1693
		 * link down event; disable receives here in the ISR and reset
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1694
		 * adapter in watchdog
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1695
		 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1696
		if (netif_carrier_ok(netdev) &&
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1697
		    adapter->flags & FLAG_RX_NEEDS_RESTART) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1698
			/* disable receives */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1699
			u32 rctl = er32(RCTL);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1700
			ew32(RCTL, rctl & ~E1000_RCTL_EN);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1701
			adapter->flags |= FLAG_RX_RESTART_NOW;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1702
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1703
		/* guard against interrupt when we're going down */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1704
		if (!test_bit(__E1000_DOWN, &adapter->state))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1705
			mod_timer(&adapter->watchdog_timer, jiffies + 1);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1706
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1707
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1708
	if (napi_schedule_prep(&adapter->napi)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1709
		adapter->total_tx_bytes = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1710
		adapter->total_tx_packets = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1711
		adapter->total_rx_bytes = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1712
		adapter->total_rx_packets = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1713
		__napi_schedule(&adapter->napi);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1714
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1715
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1716
	return IRQ_HANDLED;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1717
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1718
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1719
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1720
 * e1000_intr - Interrupt Handler
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1721
 * @irq: interrupt number
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1722
 * @data: pointer to a network interface device structure
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1723
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1724
static irqreturn_t e1000_intr(int irq, void *data)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1725
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1726
	struct net_device *netdev = data;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1727
	struct e1000_adapter *adapter = netdev_priv(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1728
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1729
	u32 rctl, icr = er32(ICR);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1730
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1731
	if (!icr || test_bit(__E1000_DOWN, &adapter->state))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1732
		return IRQ_NONE;  /* Not our interrupt */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1733
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1734
	/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1735
	 * IMS will not auto-mask if INT_ASSERTED is not set, and if it is
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1736
	 * not set, then the adapter didn't send an interrupt
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1737
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1738
	if (!adapter->ecdev && !(icr & E1000_ICR_INT_ASSERTED))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1739
		return IRQ_NONE;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1740
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1741
	/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1742
	 * Interrupt Auto-Mask...upon reading ICR,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1743
	 * interrupts are masked.  No need for the
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1744
	 * IMC write
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1745
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1746
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1747
	if (!adapter->ecdev && (icr & E1000_ICR_LSC)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1748
		hw->mac.get_link_status = 1;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1749
		/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1750
		 * ICH8 workaround-- Call gig speed drop workaround on cable
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1751
		 * disconnect (LSC) before accessing any PHY registers
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1752
		 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1753
		if ((adapter->flags & FLAG_LSC_GIG_SPEED_DROP) &&
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1754
		    (!(er32(STATUS) & E1000_STATUS_LU)))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1755
			schedule_work(&adapter->downshift_task);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1756
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1757
		/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1758
		 * 80003ES2LAN workaround--
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1759
		 * For packet buffer work-around on link down event;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1760
		 * disable receives here in the ISR and
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1761
		 * reset adapter in watchdog
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1762
		 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1763
		if (netif_carrier_ok(netdev) &&
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1764
		    (adapter->flags & FLAG_RX_NEEDS_RESTART)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1765
			/* disable receives */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1766
			rctl = er32(RCTL);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1767
			ew32(RCTL, rctl & ~E1000_RCTL_EN);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1768
			adapter->flags |= FLAG_RX_RESTART_NOW;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1769
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1770
		/* guard against interrupt when we're going down */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1771
		if (!test_bit(__E1000_DOWN, &adapter->state))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1772
			mod_timer(&adapter->watchdog_timer, jiffies + 1);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1773
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1774
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  1775
	if (adapter->ecdev) {
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  1776
		int ec_work_done = 0;
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  1777
		adapter->clean_rx(adapter, &ec_work_done, 100);
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  1778
		e1000_clean_tx_irq(adapter);
2406
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1779
		return IRQ_HANDLED;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1780
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1781
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1782
	if (napi_schedule_prep(&adapter->napi)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1783
		adapter->total_tx_bytes = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1784
		adapter->total_tx_packets = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1785
		adapter->total_rx_bytes = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1786
		adapter->total_rx_packets = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1787
		__napi_schedule(&adapter->napi);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1788
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1789
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1790
	return IRQ_HANDLED;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1791
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1792
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1793
static irqreturn_t e1000_msix_other(int irq, void *data)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1794
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1795
	struct net_device *netdev = data;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1796
	struct e1000_adapter *adapter = netdev_priv(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1797
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1798
	u32 icr = er32(ICR);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1799
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1800
	if (!(icr & E1000_ICR_INT_ASSERTED)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1801
		if (!test_bit(__E1000_DOWN, &adapter->state))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1802
			ew32(IMS, E1000_IMS_OTHER);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1803
		return IRQ_NONE;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1804
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1805
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1806
	if (icr & adapter->eiac_mask)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1807
		ew32(ICS, (icr & adapter->eiac_mask));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1808
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1809
	if (icr & E1000_ICR_OTHER) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1810
		if (!(icr & E1000_ICR_LSC))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1811
			goto no_link_interrupt;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1812
		hw->mac.get_link_status = 1;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1813
		/* guard against interrupt when we're going down */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1814
		if (!adapter->ecdev && !test_bit(__E1000_DOWN, &adapter->state))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1815
			mod_timer(&adapter->watchdog_timer, jiffies + 1);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1816
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1817
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1818
no_link_interrupt:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1819
	if (!test_bit(__E1000_DOWN, &adapter->state))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1820
		ew32(IMS, E1000_IMS_LSC | E1000_IMS_OTHER);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1821
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1822
	return IRQ_HANDLED;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1823
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1824
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1825
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1826
static irqreturn_t e1000_intr_msix_tx(int irq, void *data)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1827
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1828
	struct net_device *netdev = data;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1829
	struct e1000_adapter *adapter = netdev_priv(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1830
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1831
	struct e1000_ring *tx_ring = adapter->tx_ring;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1832
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1833
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1834
	adapter->total_tx_bytes = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1835
	adapter->total_tx_packets = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1836
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1837
	if (!e1000_clean_tx_irq(adapter))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1838
		/* Ring was not completely cleaned, so fire another interrupt */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1839
		ew32(ICS, tx_ring->ims_val);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1840
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1841
	return IRQ_HANDLED;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1842
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1843
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1844
static irqreturn_t e1000_intr_msix_rx(int irq, void *data)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1845
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1846
	struct net_device *netdev = data;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1847
	struct e1000_adapter *adapter = netdev_priv(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1848
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1849
	/* Write the ITR value calculated at the end of the
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1850
	 * previous interrupt.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1851
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1852
	if (adapter->rx_ring->set_itr) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1853
		writel(1000000000 / (adapter->rx_ring->itr_val * 256),
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1854
		       adapter->hw.hw_addr + adapter->rx_ring->itr_register);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1855
		adapter->rx_ring->set_itr = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1856
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1857
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  1858
	if (adapter->ecdev) {
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  1859
		int ec_work_done = 0;
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  1860
		adapter->clean_rx(adapter, &ec_work_done, 100);
2406
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1861
	} else {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1862
		if (napi_schedule_prep(&adapter->napi)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1863
			adapter->total_rx_bytes = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1864
			adapter->total_rx_packets = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1865
			__napi_schedule(&adapter->napi);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1866
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1867
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1868
	return IRQ_HANDLED;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1869
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1870
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1871
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1872
 * e1000_configure_msix - Configure MSI-X hardware
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1873
 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1874
 * e1000_configure_msix sets up the hardware to properly
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1875
 * generate MSI-X interrupts.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1876
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1877
static void e1000_configure_msix(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1878
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1879
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1880
	struct e1000_ring *rx_ring = adapter->rx_ring;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1881
	struct e1000_ring *tx_ring = adapter->tx_ring;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1882
	int vector = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1883
	u32 ctrl_ext, ivar = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1884
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1885
	adapter->eiac_mask = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1886
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1887
	/* Workaround issue with spurious interrupts on 82574 in MSI-X mode */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1888
	if (hw->mac.type == e1000_82574) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1889
		u32 rfctl = er32(RFCTL);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1890
		rfctl |= E1000_RFCTL_ACK_DIS;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1891
		ew32(RFCTL, rfctl);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1892
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1893
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1894
#define E1000_IVAR_INT_ALLOC_VALID	0x8
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1895
	/* Configure Rx vector */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1896
	rx_ring->ims_val = E1000_IMS_RXQ0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1897
	adapter->eiac_mask |= rx_ring->ims_val;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1898
	if (rx_ring->itr_val)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1899
		writel(1000000000 / (rx_ring->itr_val * 256),
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1900
		       hw->hw_addr + rx_ring->itr_register);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1901
	else
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1902
		writel(1, hw->hw_addr + rx_ring->itr_register);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1903
	ivar = E1000_IVAR_INT_ALLOC_VALID | vector;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1904
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1905
	/* Configure Tx vector */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1906
	tx_ring->ims_val = E1000_IMS_TXQ0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1907
	vector++;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1908
	if (tx_ring->itr_val)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1909
		writel(1000000000 / (tx_ring->itr_val * 256),
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1910
		       hw->hw_addr + tx_ring->itr_register);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1911
	else
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1912
		writel(1, hw->hw_addr + tx_ring->itr_register);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1913
	adapter->eiac_mask |= tx_ring->ims_val;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1914
	ivar |= ((E1000_IVAR_INT_ALLOC_VALID | vector) << 8);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1915
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1916
	/* set vector for Other Causes, e.g. link changes */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1917
	vector++;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1918
	ivar |= ((E1000_IVAR_INT_ALLOC_VALID | vector) << 16);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1919
	if (rx_ring->itr_val)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1920
		writel(1000000000 / (rx_ring->itr_val * 256),
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1921
		       hw->hw_addr + E1000_EITR_82574(vector));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1922
	else
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1923
		writel(1, hw->hw_addr + E1000_EITR_82574(vector));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1924
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1925
	/* Cause Tx interrupts on every write back */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1926
	ivar |= (1 << 31);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1927
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1928
	ew32(IVAR, ivar);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1929
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1930
	/* enable MSI-X PBA support */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1931
	ctrl_ext = er32(CTRL_EXT);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1932
	ctrl_ext |= E1000_CTRL_EXT_PBA_CLR;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1933
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1934
	/* Auto-Mask Other interrupts upon ICR read */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1935
#define E1000_EIAC_MASK_82574   0x01F00000
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1936
	ew32(IAM, ~E1000_EIAC_MASK_82574 | E1000_IMS_OTHER);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1937
	ctrl_ext |= E1000_CTRL_EXT_EIAME;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1938
	ew32(CTRL_EXT, ctrl_ext);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1939
	e1e_flush();
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1940
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1941
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1942
void e1000e_reset_interrupt_capability(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1943
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1944
	if (adapter->msix_entries) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1945
		pci_disable_msix(adapter->pdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1946
		kfree(adapter->msix_entries);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1947
		adapter->msix_entries = NULL;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1948
	} else if (adapter->flags & FLAG_MSI_ENABLED) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1949
		pci_disable_msi(adapter->pdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1950
		adapter->flags &= ~FLAG_MSI_ENABLED;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1951
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1952
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1953
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1954
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1955
 * e1000e_set_interrupt_capability - set MSI or MSI-X if supported
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1956
 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1957
 * Attempt to configure interrupts using the best available
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1958
 * capabilities of the hardware and kernel.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1959
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1960
void e1000e_set_interrupt_capability(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1961
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1962
	int err;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1963
	int i;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1964
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1965
	switch (adapter->int_mode) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1966
	case E1000E_INT_MODE_MSIX:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1967
		if (adapter->flags & FLAG_HAS_MSIX) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1968
			adapter->num_vectors = 3; /* RxQ0, TxQ0 and other */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1969
			adapter->msix_entries = kcalloc(adapter->num_vectors,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1970
						      sizeof(struct msix_entry),
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1971
						      GFP_KERNEL);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1972
			if (adapter->msix_entries) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1973
				for (i = 0; i < adapter->num_vectors; i++)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1974
					adapter->msix_entries[i].entry = i;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1975
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1976
				err = pci_enable_msix(adapter->pdev,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1977
						      adapter->msix_entries,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1978
						      adapter->num_vectors);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1979
				if (err == 0)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1980
					return;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1981
			}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1982
			/* MSI-X failed, so fall through and try MSI */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1983
			e_err("Failed to initialize MSI-X interrupts.  "
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1984
			      "Falling back to MSI interrupts.\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1985
			e1000e_reset_interrupt_capability(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1986
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1987
		adapter->int_mode = E1000E_INT_MODE_MSI;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1988
		/* Fall through */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1989
	case E1000E_INT_MODE_MSI:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1990
		if (!pci_enable_msi(adapter->pdev)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1991
			adapter->flags |= FLAG_MSI_ENABLED;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1992
		} else {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1993
			adapter->int_mode = E1000E_INT_MODE_LEGACY;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1994
			e_err("Failed to initialize MSI interrupts.  Falling "
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1995
			      "back to legacy interrupts.\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1996
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1997
		/* Fall through */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1998
	case E1000E_INT_MODE_LEGACY:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1999
		/* Don't do anything; this is the system default */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2000
		break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2001
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2002
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2003
	/* store the number of vectors being used */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2004
	adapter->num_vectors = 1;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2005
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2006
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2007
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2008
 * e1000_request_msix - Initialize MSI-X interrupts
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2009
 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2010
 * e1000_request_msix allocates MSI-X vectors and requests interrupts from the
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2011
 * kernel.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2012
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2013
static int e1000_request_msix(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2014
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2015
	struct net_device *netdev = adapter->netdev;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2016
	int err = 0, vector = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2017
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2018
	if (strlen(netdev->name) < (IFNAMSIZ - 5))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2019
		snprintf(adapter->rx_ring->name,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2020
			 sizeof(adapter->rx_ring->name) - 1,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2021
			 "%s-rx-0", netdev->name);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2022
	else
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2023
		memcpy(adapter->rx_ring->name, netdev->name, IFNAMSIZ);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2024
	err = request_irq(adapter->msix_entries[vector].vector,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2025
			  e1000_intr_msix_rx, 0, adapter->rx_ring->name,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2026
			  netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2027
	if (err)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2028
		goto out;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2029
	adapter->rx_ring->itr_register = E1000_EITR_82574(vector);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2030
	adapter->rx_ring->itr_val = adapter->itr;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2031
	vector++;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2032
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2033
	if (strlen(netdev->name) < (IFNAMSIZ - 5))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2034
		snprintf(adapter->tx_ring->name,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2035
			 sizeof(adapter->tx_ring->name) - 1,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2036
			 "%s-tx-0", netdev->name);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2037
	else
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2038
		memcpy(adapter->tx_ring->name, netdev->name, IFNAMSIZ);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2039
	err = request_irq(adapter->msix_entries[vector].vector,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2040
			  e1000_intr_msix_tx, 0, adapter->tx_ring->name,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2041
			  netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2042
	if (err)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2043
		goto out;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2044
	adapter->tx_ring->itr_register = E1000_EITR_82574(vector);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2045
	adapter->tx_ring->itr_val = adapter->itr;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2046
	vector++;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2047
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2048
	err = request_irq(adapter->msix_entries[vector].vector,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2049
			  e1000_msix_other, 0, netdev->name, netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2050
	if (err)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2051
		goto out;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2052
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2053
	e1000_configure_msix(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2054
	return 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2055
out:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2056
	return err;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2057
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2058
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2059
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2060
 * e1000_request_irq - initialize interrupts
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2061
 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2062
 * Attempts to configure interrupts using the best available
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2063
 * capabilities of the hardware and kernel.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2064
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2065
static int e1000_request_irq(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2066
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2067
	struct net_device *netdev = adapter->netdev;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2068
	int err;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2069
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2070
	if (adapter->ecdev)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2071
		return 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2072
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2073
	if (adapter->msix_entries) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2074
		err = e1000_request_msix(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2075
		if (!err)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2076
			return err;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2077
		/* fall back to MSI */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2078
		e1000e_reset_interrupt_capability(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2079
		adapter->int_mode = E1000E_INT_MODE_MSI;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2080
		e1000e_set_interrupt_capability(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2081
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2082
	if (adapter->flags & FLAG_MSI_ENABLED) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2083
		err = request_irq(adapter->pdev->irq, e1000_intr_msi, 0,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2084
				  netdev->name, netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2085
		if (!err)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2086
			return err;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2087
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2088
		/* fall back to legacy interrupt */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2089
		e1000e_reset_interrupt_capability(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2090
		adapter->int_mode = E1000E_INT_MODE_LEGACY;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2091
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2092
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2093
	err = request_irq(adapter->pdev->irq, e1000_intr, IRQF_SHARED,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2094
			  netdev->name, netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2095
	if (err)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2096
		e_err("Unable to allocate interrupt, Error: %d\n", err);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2097
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2098
	return err;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2099
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2100
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2101
static void e1000_free_irq(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2102
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2103
	struct net_device *netdev = adapter->netdev;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2104
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2105
	if (adapter->ecdev)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2106
		return;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2107
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2108
	if (adapter->msix_entries) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2109
		int vector = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2110
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2111
		free_irq(adapter->msix_entries[vector].vector, netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2112
		vector++;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2113
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2114
		free_irq(adapter->msix_entries[vector].vector, netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2115
		vector++;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2116
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2117
		/* Other Causes interrupt vector */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2118
		free_irq(adapter->msix_entries[vector].vector, netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2119
		return;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2120
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2121
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2122
	free_irq(adapter->pdev->irq, netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2123
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2124
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2125
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2126
 * e1000_irq_disable - Mask off interrupt generation on the NIC
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2127
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2128
static void e1000_irq_disable(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2129
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2130
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2131
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2132
	if (adapter->ecdev)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2133
		return;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2134
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2135
	ew32(IMC, ~0);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2136
	if (adapter->msix_entries)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2137
		ew32(EIAC_82574, 0);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2138
	e1e_flush();
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2139
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2140
	if (adapter->msix_entries) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2141
		int i;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2142
		for (i = 0; i < adapter->num_vectors; i++)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2143
			synchronize_irq(adapter->msix_entries[i].vector);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2144
	} else {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2145
		synchronize_irq(adapter->pdev->irq);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2146
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2147
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2148
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2149
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2150
 * e1000_irq_enable - Enable default interrupt generation settings
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2151
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2152
static void e1000_irq_enable(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2153
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2154
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2155
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2156
	if (adapter->ecdev)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2157
		return;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2158
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2159
	if (adapter->msix_entries) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2160
		ew32(EIAC_82574, adapter->eiac_mask & E1000_EIAC_MASK_82574);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2161
		ew32(IMS, adapter->eiac_mask | E1000_IMS_OTHER | E1000_IMS_LSC);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2162
	} else {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2163
		ew32(IMS, IMS_ENABLE_MASK);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2164
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2165
	e1e_flush();
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2166
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2167
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2168
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2169
 * e1000e_get_hw_control - get control of the h/w from f/w
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2170
 * @adapter: address of board private structure
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2171
 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2172
 * e1000e_get_hw_control sets {CTRL_EXT|SWSM}:DRV_LOAD bit.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2173
 * For ASF and Pass Through versions of f/w this means that
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2174
 * the driver is loaded. For AMT version (only with 82573)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2175
 * of the f/w this means that the network i/f is open.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2176
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2177
void e1000e_get_hw_control(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2178
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2179
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2180
	u32 ctrl_ext;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2181
	u32 swsm;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2182
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2183
	/* Let firmware know the driver has taken over */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2184
	if (adapter->flags & FLAG_HAS_SWSM_ON_LOAD) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2185
		swsm = er32(SWSM);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2186
		ew32(SWSM, swsm | E1000_SWSM_DRV_LOAD);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2187
	} else if (adapter->flags & FLAG_HAS_CTRLEXT_ON_LOAD) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2188
		ctrl_ext = er32(CTRL_EXT);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2189
		ew32(CTRL_EXT, ctrl_ext | E1000_CTRL_EXT_DRV_LOAD);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2190
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2191
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2192
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2193
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2194
 * e1000e_release_hw_control - release control of the h/w to f/w
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2195
 * @adapter: address of board private structure
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2196
 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2197
 * e1000e_release_hw_control resets {CTRL_EXT|SWSM}:DRV_LOAD bit.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2198
 * For ASF and Pass Through versions of f/w this means that the
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2199
 * driver is no longer loaded. For AMT version (only with 82573) i
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2200
 * of the f/w this means that the network i/f is closed.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2201
 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2202
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2203
void e1000e_release_hw_control(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2204
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2205
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2206
	u32 ctrl_ext;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2207
	u32 swsm;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2208
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2209
	/* Let firmware taken over control of h/w */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2210
	if (adapter->flags & FLAG_HAS_SWSM_ON_LOAD) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2211
		swsm = er32(SWSM);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2212
		ew32(SWSM, swsm & ~E1000_SWSM_DRV_LOAD);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2213
	} else if (adapter->flags & FLAG_HAS_CTRLEXT_ON_LOAD) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2214
		ctrl_ext = er32(CTRL_EXT);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2215
		ew32(CTRL_EXT, ctrl_ext & ~E1000_CTRL_EXT_DRV_LOAD);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2216
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2217
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2218
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2219
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2220
 * @e1000_alloc_ring - allocate memory for a ring structure
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2221
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2222
static int e1000_alloc_ring_dma(struct e1000_adapter *adapter,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2223
				struct e1000_ring *ring)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2224
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2225
	struct pci_dev *pdev = adapter->pdev;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2226
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2227
	ring->desc = dma_alloc_coherent(&pdev->dev, ring->size, &ring->dma,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2228
					GFP_KERNEL);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2229
	if (!ring->desc)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2230
		return -ENOMEM;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2231
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2232
	return 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2233
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2234
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2235
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2236
 * e1000e_setup_tx_resources - allocate Tx resources (Descriptors)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2237
 * @adapter: board private structure
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2238
 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2239
 * Return 0 on success, negative on failure
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2240
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2241
int e1000e_setup_tx_resources(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2242
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2243
	struct e1000_ring *tx_ring = adapter->tx_ring;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2244
	int err = -ENOMEM, size;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2245
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2246
	size = sizeof(struct e1000_buffer) * tx_ring->count;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2247
	tx_ring->buffer_info = vzalloc(size);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2248
	if (!tx_ring->buffer_info)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2249
		goto err;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2250
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2251
	/* round up to nearest 4K */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2252
	tx_ring->size = tx_ring->count * sizeof(struct e1000_tx_desc);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2253
	tx_ring->size = ALIGN(tx_ring->size, 4096);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2254
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2255
	err = e1000_alloc_ring_dma(adapter, tx_ring);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2256
	if (err)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2257
		goto err;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2258
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2259
	tx_ring->next_to_use = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2260
	tx_ring->next_to_clean = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2261
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2262
	return 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2263
err:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2264
	vfree(tx_ring->buffer_info);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2265
	e_err("Unable to allocate memory for the transmit descriptor ring\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2266
	return err;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2267
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2268
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2269
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2270
 * e1000e_setup_rx_resources - allocate Rx resources (Descriptors)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2271
 * @adapter: board private structure
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2272
 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2273
 * Returns 0 on success, negative on failure
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2274
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2275
int e1000e_setup_rx_resources(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2276
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2277
	struct e1000_ring *rx_ring = adapter->rx_ring;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2278
	struct e1000_buffer *buffer_info;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2279
	int i, size, desc_len, err = -ENOMEM;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2280
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2281
	size = sizeof(struct e1000_buffer) * rx_ring->count;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2282
	rx_ring->buffer_info = vzalloc(size);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2283
	if (!rx_ring->buffer_info)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2284
		goto err;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2285
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2286
	for (i = 0; i < rx_ring->count; i++) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2287
		buffer_info = &rx_ring->buffer_info[i];
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2288
		buffer_info->ps_pages = kcalloc(PS_PAGE_BUFFERS,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2289
						sizeof(struct e1000_ps_page),
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2290
						GFP_KERNEL);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2291
		if (!buffer_info->ps_pages)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2292
			goto err_pages;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2293
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2294
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2295
	desc_len = sizeof(union e1000_rx_desc_packet_split);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2296
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2297
	/* Round up to nearest 4K */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2298
	rx_ring->size = rx_ring->count * desc_len;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2299
	rx_ring->size = ALIGN(rx_ring->size, 4096);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2300
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2301
	err = e1000_alloc_ring_dma(adapter, rx_ring);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2302
	if (err)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2303
		goto err_pages;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2304
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2305
	rx_ring->next_to_clean = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2306
	rx_ring->next_to_use = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2307
	rx_ring->rx_skb_top = NULL;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2308
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2309
	return 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2310
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2311
err_pages:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2312
	for (i = 0; i < rx_ring->count; i++) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2313
		buffer_info = &rx_ring->buffer_info[i];
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2314
		kfree(buffer_info->ps_pages);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2315
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2316
err:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2317
	vfree(rx_ring->buffer_info);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2318
	e_err("Unable to allocate memory for the receive descriptor ring\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2319
	return err;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2320
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2321
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2322
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2323
 * e1000_clean_tx_ring - Free Tx Buffers
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2324
 * @adapter: board private structure
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2325
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2326
static void e1000_clean_tx_ring(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2327
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2328
	struct e1000_ring *tx_ring = adapter->tx_ring;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2329
	struct e1000_buffer *buffer_info;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2330
	unsigned long size;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2331
	unsigned int i;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2332
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2333
	for (i = 0; i < tx_ring->count; i++) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2334
		buffer_info = &tx_ring->buffer_info[i];
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2335
		e1000_put_txbuf(adapter, buffer_info);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2336
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2337
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2338
	size = sizeof(struct e1000_buffer) * tx_ring->count;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2339
	memset(tx_ring->buffer_info, 0, size);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2340
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2341
	memset(tx_ring->desc, 0, tx_ring->size);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2342
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2343
	tx_ring->next_to_use = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2344
	tx_ring->next_to_clean = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2345
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2346
	writel(0, adapter->hw.hw_addr + tx_ring->head);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2347
	writel(0, adapter->hw.hw_addr + tx_ring->tail);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2348
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2349
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2350
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2351
 * e1000e_free_tx_resources - Free Tx Resources per Queue
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2352
 * @adapter: board private structure
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2353
 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2354
 * Free all transmit software resources
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2355
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2356
void e1000e_free_tx_resources(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2357
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2358
	struct pci_dev *pdev = adapter->pdev;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2359
	struct e1000_ring *tx_ring = adapter->tx_ring;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2360
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2361
	e1000_clean_tx_ring(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2362
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2363
	vfree(tx_ring->buffer_info);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2364
	tx_ring->buffer_info = NULL;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2365
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2366
	dma_free_coherent(&pdev->dev, tx_ring->size, tx_ring->desc,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2367
			  tx_ring->dma);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2368
	tx_ring->desc = NULL;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2369
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2370
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2371
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2372
 * e1000e_free_rx_resources - Free Rx Resources
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2373
 * @adapter: board private structure
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2374
 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2375
 * Free all receive software resources
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2376
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2377
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2378
void e1000e_free_rx_resources(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2379
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2380
	struct pci_dev *pdev = adapter->pdev;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2381
	struct e1000_ring *rx_ring = adapter->rx_ring;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2382
	int i;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2383
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2384
	e1000_clean_rx_ring(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2385
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2386
	for (i = 0; i < rx_ring->count; i++)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2387
		kfree(rx_ring->buffer_info[i].ps_pages);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2388
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2389
	vfree(rx_ring->buffer_info);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2390
	rx_ring->buffer_info = NULL;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2391
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2392
	dma_free_coherent(&pdev->dev, rx_ring->size, rx_ring->desc,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2393
			  rx_ring->dma);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2394
	rx_ring->desc = NULL;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2395
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2396
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2397
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2398
 * e1000_update_itr - update the dynamic ITR value based on statistics
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2399
 * @adapter: pointer to adapter
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2400
 * @itr_setting: current adapter->itr
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2401
 * @packets: the number of packets during this measurement interval
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2402
 * @bytes: the number of bytes during this measurement interval
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2403
 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2404
 *      Stores a new ITR value based on packets and byte
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2405
 *      counts during the last interrupt.  The advantage of per interrupt
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2406
 *      computation is faster updates and more accurate ITR for the current
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2407
 *      traffic pattern.  Constants in this function were computed
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2408
 *      based on theoretical maximum wire speed and thresholds were set based
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2409
 *      on testing data as well as attempting to minimize response time
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2410
 *      while increasing bulk throughput.  This functionality is controlled
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2411
 *      by the InterruptThrottleRate module parameter.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2412
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2413
static unsigned int e1000_update_itr(struct e1000_adapter *adapter,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2414
				     u16 itr_setting, int packets,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2415
				     int bytes)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2416
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2417
	unsigned int retval = itr_setting;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2418
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2419
	if (packets == 0)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2420
		goto update_itr_done;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2421
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2422
	switch (itr_setting) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2423
	case lowest_latency:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2424
		/* handle TSO and jumbo frames */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2425
		if (bytes/packets > 8000)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2426
			retval = bulk_latency;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2427
		else if ((packets < 5) && (bytes > 512))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2428
			retval = low_latency;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2429
		break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2430
	case low_latency:  /* 50 usec aka 20000 ints/s */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2431
		if (bytes > 10000) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2432
			/* this if handles the TSO accounting */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2433
			if (bytes/packets > 8000)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2434
				retval = bulk_latency;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2435
			else if ((packets < 10) || ((bytes/packets) > 1200))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2436
				retval = bulk_latency;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2437
			else if ((packets > 35))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2438
				retval = lowest_latency;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2439
		} else if (bytes/packets > 2000) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2440
			retval = bulk_latency;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2441
		} else if (packets <= 2 && bytes < 512) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2442
			retval = lowest_latency;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2443
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2444
		break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2445
	case bulk_latency: /* 250 usec aka 4000 ints/s */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2446
		if (bytes > 25000) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2447
			if (packets > 35)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2448
				retval = low_latency;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2449
		} else if (bytes < 6000) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2450
			retval = low_latency;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2451
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2452
		break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2453
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2454
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2455
update_itr_done:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2456
	return retval;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2457
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2458
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2459
static void e1000_set_itr(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2460
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2461
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2462
	u16 current_itr;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2463
	u32 new_itr = adapter->itr;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2464
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2465
	/* for non-gigabit speeds, just fix the interrupt rate at 4000 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2466
	if (adapter->link_speed != SPEED_1000) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2467
		current_itr = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2468
		new_itr = 4000;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2469
		goto set_itr_now;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2470
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2471
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2472
	if (adapter->flags2 & FLAG2_DISABLE_AIM) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2473
		new_itr = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2474
		goto set_itr_now;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2475
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2476
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2477
	adapter->tx_itr = e1000_update_itr(adapter,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2478
				    adapter->tx_itr,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2479
				    adapter->total_tx_packets,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2480
				    adapter->total_tx_bytes);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2481
	/* conservative mode (itr 3) eliminates the lowest_latency setting */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2482
	if (adapter->itr_setting == 3 && adapter->tx_itr == lowest_latency)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2483
		adapter->tx_itr = low_latency;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2484
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2485
	adapter->rx_itr = e1000_update_itr(adapter,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2486
				    adapter->rx_itr,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2487
				    adapter->total_rx_packets,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2488
				    adapter->total_rx_bytes);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2489
	/* conservative mode (itr 3) eliminates the lowest_latency setting */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2490
	if (adapter->itr_setting == 3 && adapter->rx_itr == lowest_latency)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2491
		adapter->rx_itr = low_latency;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2492
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2493
	current_itr = max(adapter->rx_itr, adapter->tx_itr);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2494
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2495
	switch (current_itr) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2496
	/* counts and packets in update_itr are dependent on these numbers */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2497
	case lowest_latency:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2498
		new_itr = 70000;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2499
		break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2500
	case low_latency:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2501
		new_itr = 20000; /* aka hwitr = ~200 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2502
		break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2503
	case bulk_latency:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2504
		new_itr = 4000;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2505
		break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2506
	default:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2507
		break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2508
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2509
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2510
set_itr_now:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2511
	if (new_itr != adapter->itr) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2512
		/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2513
		 * this attempts to bias the interrupt rate towards Bulk
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2514
		 * by adding intermediate steps when interrupt rate is
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2515
		 * increasing
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2516
		 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2517
		new_itr = new_itr > adapter->itr ?
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2518
			     min(adapter->itr + (new_itr >> 2), new_itr) :
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2519
			     new_itr;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2520
		adapter->itr = new_itr;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2521
		adapter->rx_ring->itr_val = new_itr;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2522
		if (adapter->msix_entries)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2523
			adapter->rx_ring->set_itr = 1;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2524
		else
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2525
			if (new_itr)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2526
				ew32(ITR, 1000000000 / (new_itr * 256));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2527
			else
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2528
				ew32(ITR, 0);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2529
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2530
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2531
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2532
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2533
 * e1000_alloc_queues - Allocate memory for all rings
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2534
 * @adapter: board private structure to initialize
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2535
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2536
static int __devinit e1000_alloc_queues(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2537
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2538
	adapter->tx_ring = kzalloc(sizeof(struct e1000_ring), GFP_KERNEL);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2539
	if (!adapter->tx_ring)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2540
		goto err;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2541
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2542
	adapter->rx_ring = kzalloc(sizeof(struct e1000_ring), GFP_KERNEL);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2543
	if (!adapter->rx_ring)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2544
		goto err;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2545
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2546
	return 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2547
err:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2548
	e_err("Unable to allocate memory for queues\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2549
	kfree(adapter->rx_ring);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2550
	kfree(adapter->tx_ring);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2551
	return -ENOMEM;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2552
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2553
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2554
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2555
 * e1000_clean - NAPI Rx polling callback
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2556
 * @napi: struct associated with this polling callback
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2557
 * @budget: amount of packets driver is allowed to process this poll
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2558
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2559
static int e1000_clean(struct napi_struct *napi, int budget)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2560
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2561
	struct e1000_adapter *adapter = container_of(napi, struct e1000_adapter, napi);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2562
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2563
	struct net_device *poll_dev = adapter->netdev;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2564
	int tx_cleaned = 1, work_done = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2565
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2566
	adapter = netdev_priv(poll_dev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2567
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2568
	if (adapter->msix_entries &&
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2569
	    !(adapter->rx_ring->ims_val & adapter->tx_ring->ims_val))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2570
		goto clean_rx;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2571
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2572
	tx_cleaned = e1000_clean_tx_irq(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2573
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2574
clean_rx:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2575
	adapter->clean_rx(adapter, &work_done, budget);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2576
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2577
	if (!tx_cleaned)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2578
		work_done = budget;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2579
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2580
	/* If budget not fully consumed, exit the polling mode */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2581
	if (work_done < budget) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2582
		if (adapter->itr_setting & 3)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2583
			e1000_set_itr(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2584
		napi_complete(napi);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2585
		if (!test_bit(__E1000_DOWN, &adapter->state)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2586
			if (adapter->msix_entries)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2587
				ew32(IMS, adapter->rx_ring->ims_val);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2588
			else
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2589
				e1000_irq_enable(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2590
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2591
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2592
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2593
	return work_done;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2594
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2595
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2596
static void e1000_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2597
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2598
	struct e1000_adapter *adapter = netdev_priv(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2599
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2600
	u32 vfta, index;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2601
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2602
	/* don't update vlan cookie if already programmed */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2603
	if ((adapter->hw.mng_cookie.status &
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2604
	     E1000_MNG_DHCP_COOKIE_STATUS_VLAN) &&
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2605
	    (vid == adapter->mng_vlan_id))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2606
		return;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2607
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2608
	/* add VID to filter table */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2609
	if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2610
		index = (vid >> 5) & 0x7F;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2611
		vfta = E1000_READ_REG_ARRAY(hw, E1000_VFTA, index);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2612
		vfta |= (1 << (vid & 0x1F));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2613
		hw->mac.ops.write_vfta(hw, index, vfta);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2614
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2615
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2616
	set_bit(vid, adapter->active_vlans);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2617
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2618
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2619
static void e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2620
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2621
	struct e1000_adapter *adapter = netdev_priv(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2622
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2623
	u32 vfta, index;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2624
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2625
	if ((adapter->hw.mng_cookie.status &
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2626
	     E1000_MNG_DHCP_COOKIE_STATUS_VLAN) &&
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2627
	    (vid == adapter->mng_vlan_id)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2628
		/* release control to f/w */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2629
		e1000e_release_hw_control(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2630
		return;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2631
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2632
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2633
	/* remove VID from filter table */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2634
	if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2635
		index = (vid >> 5) & 0x7F;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2636
		vfta = E1000_READ_REG_ARRAY(hw, E1000_VFTA, index);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2637
		vfta &= ~(1 << (vid & 0x1F));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2638
		hw->mac.ops.write_vfta(hw, index, vfta);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2639
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2640
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2641
	clear_bit(vid, adapter->active_vlans);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2642
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2643
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2644
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2645
 * e1000e_vlan_filter_disable - helper to disable hw VLAN filtering
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2646
 * @adapter: board private structure to initialize
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2647
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2648
static void e1000e_vlan_filter_disable(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2649
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2650
	struct net_device *netdev = adapter->netdev;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2651
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2652
	u32 rctl;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2653
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2654
	if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2655
		/* disable VLAN receive filtering */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2656
		rctl = er32(RCTL);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2657
		rctl &= ~(E1000_RCTL_VFE | E1000_RCTL_CFIEN);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2658
		ew32(RCTL, rctl);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2659
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2660
		if (adapter->mng_vlan_id != (u16)E1000_MNG_VLAN_NONE) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2661
			e1000_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2662
			adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2663
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2664
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2665
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2666
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2667
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2668
 * e1000e_vlan_filter_enable - helper to enable HW VLAN filtering
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2669
 * @adapter: board private structure to initialize
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2670
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2671
static void e1000e_vlan_filter_enable(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2672
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2673
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2674
	u32 rctl;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2675
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2676
	if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2677
		/* enable VLAN receive filtering */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2678
		rctl = er32(RCTL);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2679
		rctl |= E1000_RCTL_VFE;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2680
		rctl &= ~E1000_RCTL_CFIEN;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2681
		ew32(RCTL, rctl);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2682
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2683
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2684
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2685
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2686
 * e1000e_vlan_strip_enable - helper to disable HW VLAN stripping
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2687
 * @adapter: board private structure to initialize
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2688
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2689
static void e1000e_vlan_strip_disable(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2690
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2691
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2692
	u32 ctrl;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2693
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2694
	/* disable VLAN tag insert/strip */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2695
	ctrl = er32(CTRL);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2696
	ctrl &= ~E1000_CTRL_VME;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2697
	ew32(CTRL, ctrl);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2698
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2699
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2700
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2701
 * e1000e_vlan_strip_enable - helper to enable HW VLAN stripping
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2702
 * @adapter: board private structure to initialize
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2703
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2704
static void e1000e_vlan_strip_enable(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2705
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2706
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2707
	u32 ctrl;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2708
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2709
	/* enable VLAN tag insert/strip */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2710
	ctrl = er32(CTRL);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2711
	ctrl |= E1000_CTRL_VME;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2712
	ew32(CTRL, ctrl);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2713
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2714
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2715
static void e1000_update_mng_vlan(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2716
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2717
	struct net_device *netdev = adapter->netdev;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2718
	u16 vid = adapter->hw.mng_cookie.vlan_id;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2719
	u16 old_vid = adapter->mng_vlan_id;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2720
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2721
	if (adapter->hw.mng_cookie.status &
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2722
	    E1000_MNG_DHCP_COOKIE_STATUS_VLAN) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2723
		e1000_vlan_rx_add_vid(netdev, vid);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2724
		adapter->mng_vlan_id = vid;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2725
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2726
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2727
	if ((old_vid != (u16)E1000_MNG_VLAN_NONE) && (vid != old_vid))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2728
		e1000_vlan_rx_kill_vid(netdev, old_vid);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2729
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2730
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2731
static void e1000_restore_vlan(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2732
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2733
	u16 vid;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2734
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2735
	e1000_vlan_rx_add_vid(adapter->netdev, 0);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2736
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2737
	for_each_set_bit(vid, adapter->active_vlans, VLAN_N_VID)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2738
		e1000_vlan_rx_add_vid(adapter->netdev, vid);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2739
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2740
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2741
static void e1000_init_manageability_pt(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2742
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2743
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2744
	u32 manc, manc2h, mdef, i, j;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2745
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2746
	if (!(adapter->flags & FLAG_MNG_PT_ENABLED))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2747
		return;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2748
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2749
	manc = er32(MANC);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2750
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2751
	/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2752
	 * enable receiving management packets to the host. this will probably
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2753
	 * generate destination unreachable messages from the host OS, but
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2754
	 * the packets will be handled on SMBUS
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2755
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2756
	manc |= E1000_MANC_EN_MNG2HOST;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2757
	manc2h = er32(MANC2H);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2758
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2759
	switch (hw->mac.type) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2760
	default:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2761
		manc2h |= (E1000_MANC2H_PORT_623 | E1000_MANC2H_PORT_664);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2762
		break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2763
	case e1000_82574:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2764
	case e1000_82583:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2765
		/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2766
		 * Check if IPMI pass-through decision filter already exists;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2767
		 * if so, enable it.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2768
		 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2769
		for (i = 0, j = 0; i < 8; i++) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2770
			mdef = er32(MDEF(i));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2771
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2772
			/* Ignore filters with anything other than IPMI ports */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2773
			if (mdef & ~(E1000_MDEF_PORT_623 | E1000_MDEF_PORT_664))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2774
				continue;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2775
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2776
			/* Enable this decision filter in MANC2H */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2777
			if (mdef)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2778
				manc2h |= (1 << i);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2779
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2780
			j |= mdef;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2781
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2782
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2783
		if (j == (E1000_MDEF_PORT_623 | E1000_MDEF_PORT_664))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2784
			break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2785
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2786
		/* Create new decision filter in an empty filter */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2787
		for (i = 0, j = 0; i < 8; i++)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2788
			if (er32(MDEF(i)) == 0) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2789
				ew32(MDEF(i), (E1000_MDEF_PORT_623 |
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2790
					       E1000_MDEF_PORT_664));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2791
				manc2h |= (1 << 1);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2792
				j++;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2793
				break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2794
			}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2795
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2796
		if (!j)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2797
			e_warn("Unable to create IPMI pass-through filter\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2798
		break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2799
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2800
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2801
	ew32(MANC2H, manc2h);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2802
	ew32(MANC, manc);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2803
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2804
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2805
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2806
 * e1000_configure_tx - Configure Transmit Unit after Reset
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2807
 * @adapter: board private structure
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2808
 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2809
 * Configure the Tx unit of the MAC after a reset.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2810
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2811
static void e1000_configure_tx(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2812
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2813
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2814
	struct e1000_ring *tx_ring = adapter->tx_ring;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2815
	u64 tdba;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2816
	u32 tdlen, tctl, tipg, tarc;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2817
	u32 ipgr1, ipgr2;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2818
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2819
	/* Setup the HW Tx Head and Tail descriptor pointers */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2820
	tdba = tx_ring->dma;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2821
	tdlen = tx_ring->count * sizeof(struct e1000_tx_desc);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2822
	ew32(TDBAL, (tdba & DMA_BIT_MASK(32)));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2823
	ew32(TDBAH, (tdba >> 32));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2824
	ew32(TDLEN, tdlen);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2825
	ew32(TDH, 0);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2826
	ew32(TDT, 0);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2827
	tx_ring->head = E1000_TDH;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2828
	tx_ring->tail = E1000_TDT;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2829
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2830
	/* Set the default values for the Tx Inter Packet Gap timer */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2831
	tipg = DEFAULT_82543_TIPG_IPGT_COPPER;          /*  8  */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2832
	ipgr1 = DEFAULT_82543_TIPG_IPGR1;               /*  8  */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2833
	ipgr2 = DEFAULT_82543_TIPG_IPGR2;               /*  6  */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2834
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2835
	if (adapter->flags & FLAG_TIPG_MEDIUM_FOR_80003ESLAN)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2836
		ipgr2 = DEFAULT_80003ES2LAN_TIPG_IPGR2; /*  7  */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2837
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2838
	tipg |= ipgr1 << E1000_TIPG_IPGR1_SHIFT;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2839
	tipg |= ipgr2 << E1000_TIPG_IPGR2_SHIFT;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2840
	ew32(TIPG, tipg);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2841
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2842
	/* Set the Tx Interrupt Delay register */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2843
	ew32(TIDV, adapter->tx_int_delay);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2844
	/* Tx irq moderation */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2845
	ew32(TADV, adapter->tx_abs_int_delay);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2846
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2847
	if (adapter->flags2 & FLAG2_DMA_BURST) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2848
		u32 txdctl = er32(TXDCTL(0));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2849
		txdctl &= ~(E1000_TXDCTL_PTHRESH | E1000_TXDCTL_HTHRESH |
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2850
			    E1000_TXDCTL_WTHRESH);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2851
		/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2852
		 * set up some performance related parameters to encourage the
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2853
		 * hardware to use the bus more efficiently in bursts, depends
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2854
		 * on the tx_int_delay to be enabled,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2855
		 * wthresh = 5 ==> burst write a cacheline (64 bytes) at a time
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2856
		 * hthresh = 1 ==> prefetch when one or more available
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2857
		 * pthresh = 0x1f ==> prefetch if internal cache 31 or less
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2858
		 * BEWARE: this seems to work but should be considered first if
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2859
		 * there are Tx hangs or other Tx related bugs
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2860
		 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2861
		txdctl |= E1000_TXDCTL_DMA_BURST_ENABLE;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2862
		ew32(TXDCTL(0), txdctl);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2863
		/* erratum work around: set txdctl the same for both queues */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2864
		ew32(TXDCTL(1), txdctl);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2865
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2866
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2867
	/* Program the Transmit Control Register */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2868
	tctl = er32(TCTL);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2869
	tctl &= ~E1000_TCTL_CT;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2870
	tctl |= E1000_TCTL_PSP | E1000_TCTL_RTLC |
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2871
		(E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2872
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2873
	if (adapter->flags & FLAG_TARC_SPEED_MODE_BIT) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2874
		tarc = er32(TARC(0));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2875
		/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2876
		 * set the speed mode bit, we'll clear it if we're not at
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2877
		 * gigabit link later
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2878
		 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2879
#define SPEED_MODE_BIT (1 << 21)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2880
		tarc |= SPEED_MODE_BIT;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2881
		ew32(TARC(0), tarc);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2882
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2883
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2884
	/* errata: program both queues to unweighted RR */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2885
	if (adapter->flags & FLAG_TARC_SET_BIT_ZERO) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2886
		tarc = er32(TARC(0));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2887
		tarc |= 1;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2888
		ew32(TARC(0), tarc);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2889
		tarc = er32(TARC(1));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2890
		tarc |= 1;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2891
		ew32(TARC(1), tarc);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2892
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2893
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2894
	/* Setup Transmit Descriptor Settings for eop descriptor */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2895
	adapter->txd_cmd = E1000_TXD_CMD_EOP | E1000_TXD_CMD_IFCS;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2896
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2897
	/* only set IDE if we are delaying interrupts using the timers */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2898
	if (adapter->tx_int_delay)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2899
		adapter->txd_cmd |= E1000_TXD_CMD_IDE;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2900
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2901
	/* enable Report Status bit */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2902
	adapter->txd_cmd |= E1000_TXD_CMD_RS;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2903
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2904
	ew32(TCTL, tctl);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2905
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2906
	e1000e_config_collision_dist(hw);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2907
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2908
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2909
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2910
 * e1000_setup_rctl - configure the receive control registers
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2911
 * @adapter: Board private structure
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2912
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2913
#define PAGE_USE_COUNT(S) (((S) >> PAGE_SHIFT) + \
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2914
			   (((S) & (PAGE_SIZE - 1)) ? 1 : 0))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2915
static void e1000_setup_rctl(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2916
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2917
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2918
	u32 rctl, rfctl;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2919
	u32 pages = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2920
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2921
	/* Workaround Si errata on 82579 - configure jumbo frame flow */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2922
	if (hw->mac.type == e1000_pch2lan) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2923
		s32 ret_val __attribute__ ((unused));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2924
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2925
		if (adapter->netdev->mtu > ETH_DATA_LEN)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2926
			ret_val = e1000_lv_jumbo_workaround_ich8lan(hw, true);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2927
		else
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2928
			ret_val = e1000_lv_jumbo_workaround_ich8lan(hw, false);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2929
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2930
		if (ret_val)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2931
			e_dbg("failed to enable jumbo frame workaround mode\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2932
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2933
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2934
	/* Program MC offset vector base */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2935
	rctl = er32(RCTL);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2936
	rctl &= ~(3 << E1000_RCTL_MO_SHIFT);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2937
	rctl |= E1000_RCTL_EN | E1000_RCTL_BAM |
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2938
		E1000_RCTL_LBM_NO | E1000_RCTL_RDMTS_HALF |
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2939
		(adapter->hw.mac.mc_filter_type << E1000_RCTL_MO_SHIFT);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2940
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2941
	/* Do not Store bad packets */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2942
	rctl &= ~E1000_RCTL_SBP;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2943
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2944
	/* Enable Long Packet receive */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2945
	if (adapter->netdev->mtu <= ETH_DATA_LEN)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2946
		rctl &= ~E1000_RCTL_LPE;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2947
	else
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2948
		rctl |= E1000_RCTL_LPE;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2949
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2950
	/* Some systems expect that the CRC is included in SMBUS traffic. The
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2951
	 * hardware strips the CRC before sending to both SMBUS (BMC) and to
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2952
	 * host memory when this is enabled
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2953
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2954
	if (adapter->flags2 & FLAG2_CRC_STRIPPING)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2955
		rctl |= E1000_RCTL_SECRC;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2956
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2957
	/* Workaround Si errata on 82577 PHY - configure IPG for jumbos */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2958
	if ((hw->phy.type == e1000_phy_82577) && (rctl & E1000_RCTL_LPE)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2959
		u16 phy_data;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2960
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2961
		e1e_rphy(hw, PHY_REG(770, 26), &phy_data);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2962
		phy_data &= 0xfff8;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2963
		phy_data |= (1 << 2);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2964
		e1e_wphy(hw, PHY_REG(770, 26), phy_data);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2965
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2966
		e1e_rphy(hw, 22, &phy_data);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2967
		phy_data &= 0x0fff;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2968
		phy_data |= (1 << 14);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2969
		e1e_wphy(hw, 0x10, 0x2823);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2970
		e1e_wphy(hw, 0x11, 0x0003);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2971
		e1e_wphy(hw, 22, phy_data);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2972
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2973
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2974
	/* Setup buffer sizes */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2975
	rctl &= ~E1000_RCTL_SZ_4096;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2976
	rctl |= E1000_RCTL_BSEX;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2977
	switch (adapter->rx_buffer_len) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2978
	case 2048:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2979
	default:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2980
		rctl |= E1000_RCTL_SZ_2048;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2981
		rctl &= ~E1000_RCTL_BSEX;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2982
		break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2983
	case 4096:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2984
		rctl |= E1000_RCTL_SZ_4096;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2985
		break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2986
	case 8192:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2987
		rctl |= E1000_RCTL_SZ_8192;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2988
		break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2989
	case 16384:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2990
		rctl |= E1000_RCTL_SZ_16384;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2991
		break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2992
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2993
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2994
	/* Enable Extended Status in all Receive Descriptors */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2995
	rfctl = er32(RFCTL);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2996
	rfctl |= E1000_RFCTL_EXTEN;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2997
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2998
	/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2999
	 * 82571 and greater support packet-split where the protocol
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3000
	 * header is placed in skb->data and the packet data is
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3001
	 * placed in pages hanging off of skb_shinfo(skb)->nr_frags.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3002
	 * In the case of a non-split, skb->data is linearly filled,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3003
	 * followed by the page buffers.  Therefore, skb->data is
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3004
	 * sized to hold the largest protocol header.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3005
	 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3006
	 * allocations using alloc_page take too long for regular MTU
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3007
	 * so only enable packet split for jumbo frames
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3008
	 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3009
	 * Using pages when the page size is greater than 16k wastes
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3010
	 * a lot of memory, since we allocate 3 pages at all times
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3011
	 * per packet.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3012
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3013
	pages = PAGE_USE_COUNT(adapter->netdev->mtu);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3014
	if (!(adapter->flags & FLAG_HAS_ERT) && (pages <= 3) &&
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3015
	    (PAGE_SIZE <= 16384) && (rctl & E1000_RCTL_LPE))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3016
		adapter->rx_ps_pages = pages;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3017
	else
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3018
		adapter->rx_ps_pages = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3019
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3020
	if (adapter->rx_ps_pages) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3021
		u32 psrctl = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3022
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3023
		/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3024
		 * disable packet split support for IPv6 extension headers,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3025
		 * because some malformed IPv6 headers can hang the Rx
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3026
		 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3027
		rfctl |= (E1000_RFCTL_IPV6_EX_DIS |
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3028
			  E1000_RFCTL_NEW_IPV6_EXT_DIS);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3029
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3030
		/* Enable Packet split descriptors */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3031
		rctl |= E1000_RCTL_DTYP_PS;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3032
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3033
		psrctl |= adapter->rx_ps_bsize0 >>
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3034
			E1000_PSRCTL_BSIZE0_SHIFT;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3035
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3036
		switch (adapter->rx_ps_pages) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3037
		case 3:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3038
			psrctl |= PAGE_SIZE <<
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3039
				E1000_PSRCTL_BSIZE3_SHIFT;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3040
		case 2:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3041
			psrctl |= PAGE_SIZE <<
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3042
				E1000_PSRCTL_BSIZE2_SHIFT;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3043
		case 1:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3044
			psrctl |= PAGE_SIZE >>
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3045
				E1000_PSRCTL_BSIZE1_SHIFT;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3046
			break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3047
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3048
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3049
		ew32(PSRCTL, psrctl);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3050
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3051
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3052
	ew32(RFCTL, rfctl);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3053
	ew32(RCTL, rctl);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3054
	/* just started the receive unit, no need to restart */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3055
	adapter->flags &= ~FLAG_RX_RESTART_NOW;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3056
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3057
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3058
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3059
 * e1000_configure_rx - Configure Receive Unit after Reset
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3060
 * @adapter: board private structure
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3061
 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3062
 * Configure the Rx unit of the MAC after a reset.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3063
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3064
static void e1000_configure_rx(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3065
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3066
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3067
	struct e1000_ring *rx_ring = adapter->rx_ring;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3068
	u64 rdba;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3069
	u32 rdlen, rctl, rxcsum, ctrl_ext;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3070
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3071
	if (adapter->rx_ps_pages) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3072
		/* this is a 32 byte descriptor */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3073
		rdlen = rx_ring->count *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3074
		    sizeof(union e1000_rx_desc_packet_split);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3075
		adapter->clean_rx = e1000_clean_rx_irq_ps;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3076
		adapter->alloc_rx_buf = e1000_alloc_rx_buffers_ps;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3077
	} else if (adapter->netdev->mtu > ETH_FRAME_LEN + ETH_FCS_LEN) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3078
		rdlen = rx_ring->count * sizeof(union e1000_rx_desc_extended);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3079
		adapter->clean_rx = e1000_clean_jumbo_rx_irq;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3080
		adapter->alloc_rx_buf = e1000_alloc_jumbo_rx_buffers;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3081
	} else {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3082
		rdlen = rx_ring->count * sizeof(union e1000_rx_desc_extended);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3083
		adapter->clean_rx = e1000_clean_rx_irq;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3084
		adapter->alloc_rx_buf = e1000_alloc_rx_buffers;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3085
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3086
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3087
	/* disable receives while setting up the descriptors */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3088
	rctl = er32(RCTL);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3089
	if (!(adapter->flags2 & FLAG2_NO_DISABLE_RX))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3090
		ew32(RCTL, rctl & ~E1000_RCTL_EN);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3091
	e1e_flush();
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3092
	usleep_range(10000, 20000);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3093
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3094
	if (adapter->flags2 & FLAG2_DMA_BURST) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3095
		/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3096
		 * set the writeback threshold (only takes effect if the RDTR
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3097
		 * is set). set GRAN=1 and write back up to 0x4 worth, and
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3098
		 * enable prefetching of 0x20 Rx descriptors
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3099
		 * granularity = 01
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3100
		 * wthresh = 04,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3101
		 * hthresh = 04,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3102
		 * pthresh = 0x20
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3103
		 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3104
		ew32(RXDCTL(0), E1000_RXDCTL_DMA_BURST_ENABLE);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3105
		ew32(RXDCTL(1), E1000_RXDCTL_DMA_BURST_ENABLE);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3106
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3107
		/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3108
		 * override the delay timers for enabling bursting, only if
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3109
		 * the value was not set by the user via module options
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3110
		 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3111
		if (adapter->rx_int_delay == DEFAULT_RDTR)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3112
			adapter->rx_int_delay = BURST_RDTR;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3113
		if (adapter->rx_abs_int_delay == DEFAULT_RADV)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3114
			adapter->rx_abs_int_delay = BURST_RADV;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3115
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3116
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3117
	/* set the Receive Delay Timer Register */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3118
	ew32(RDTR, adapter->rx_int_delay);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3119
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3120
	/* irq moderation */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3121
	ew32(RADV, adapter->rx_abs_int_delay);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3122
	if ((adapter->itr_setting != 0) && (adapter->itr != 0))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3123
		ew32(ITR, 1000000000 / (adapter->itr * 256));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3124
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3125
	ctrl_ext = er32(CTRL_EXT);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3126
	/* Auto-Mask interrupts upon ICR access */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3127
	ctrl_ext |= E1000_CTRL_EXT_IAME;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3128
	ew32(IAM, 0xffffffff);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3129
	ew32(CTRL_EXT, ctrl_ext);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3130
	e1e_flush();
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3131
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3132
	/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3133
	 * Setup the HW Rx Head and Tail Descriptor Pointers and
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3134
	 * the Base and Length of the Rx Descriptor Ring
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3135
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3136
	rdba = rx_ring->dma;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3137
	ew32(RDBAL, (rdba & DMA_BIT_MASK(32)));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3138
	ew32(RDBAH, (rdba >> 32));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3139
	ew32(RDLEN, rdlen);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3140
	ew32(RDH, 0);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3141
	ew32(RDT, 0);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3142
	rx_ring->head = E1000_RDH;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3143
	rx_ring->tail = E1000_RDT;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3144
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3145
	/* Enable Receive Checksum Offload for TCP and UDP */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3146
	rxcsum = er32(RXCSUM);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3147
	if (adapter->netdev->features & NETIF_F_RXCSUM) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3148
		rxcsum |= E1000_RXCSUM_TUOFL;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3149
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3150
		/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3151
		 * IPv4 payload checksum for UDP fragments must be
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3152
		 * used in conjunction with packet-split.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3153
		 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3154
		if (adapter->rx_ps_pages)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3155
			rxcsum |= E1000_RXCSUM_IPPCSE;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3156
	} else {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3157
		rxcsum &= ~E1000_RXCSUM_TUOFL;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3158
		/* no need to clear IPPCSE as it defaults to 0 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3159
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3160
	ew32(RXCSUM, rxcsum);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3161
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3162
	/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3163
	 * Enable early receives on supported devices, only takes effect when
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3164
	 * packet size is equal or larger than the specified value (in 8 byte
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3165
	 * units), e.g. using jumbo frames when setting to E1000_ERT_2048
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3166
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3167
	if ((adapter->flags & FLAG_HAS_ERT) ||
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3168
	    (adapter->hw.mac.type == e1000_pch2lan)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3169
		if (adapter->netdev->mtu > ETH_DATA_LEN) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3170
			u32 rxdctl = er32(RXDCTL(0));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3171
			ew32(RXDCTL(0), rxdctl | 0x3);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3172
			if (adapter->flags & FLAG_HAS_ERT)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3173
				ew32(ERT, E1000_ERT_2048 | (1 << 13));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3174
			/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3175
			 * With jumbo frames and early-receive enabled,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3176
			 * excessive C-state transition latencies result in
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3177
			 * dropped transactions.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3178
			 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3179
			pm_qos_update_request(&adapter->netdev->pm_qos_req, 55);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3180
		} else {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3181
			pm_qos_update_request(&adapter->netdev->pm_qos_req,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3182
					      PM_QOS_DEFAULT_VALUE);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3183
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3184
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3185
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3186
	/* Enable Receives */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3187
	ew32(RCTL, rctl);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3188
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3189
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3190
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3191
 *  e1000_update_mc_addr_list - Update Multicast addresses
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3192
 *  @hw: pointer to the HW structure
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3193
 *  @mc_addr_list: array of multicast addresses to program
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3194
 *  @mc_addr_count: number of multicast addresses to program
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3195
 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3196
 *  Updates the Multicast Table Array.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3197
 *  The caller must have a packed mc_addr_list of multicast addresses.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3198
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3199
static void e1000_update_mc_addr_list(struct e1000_hw *hw, u8 *mc_addr_list,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3200
				      u32 mc_addr_count)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3201
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3202
	hw->mac.ops.update_mc_addr_list(hw, mc_addr_list, mc_addr_count);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3203
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3204
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3205
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3206
 * e1000_set_multi - Multicast and Promiscuous mode set
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3207
 * @netdev: network interface device structure
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3208
 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3209
 * The set_multi entry point is called whenever the multicast address
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3210
 * list or the network interface flags are updated.  This routine is
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3211
 * responsible for configuring the hardware for proper multicast,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3212
 * promiscuous mode, and all-multi behavior.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3213
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3214
static void e1000_set_multi(struct net_device *netdev)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3215
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3216
	struct e1000_adapter *adapter = netdev_priv(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3217
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3218
	struct netdev_hw_addr *ha;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3219
	u8  *mta_list;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3220
	u32 rctl;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3221
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3222
	/* Check for Promiscuous and All Multicast modes */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3223
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3224
	rctl = er32(RCTL);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3225
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3226
	if (netdev->flags & IFF_PROMISC) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3227
		rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3228
		rctl &= ~E1000_RCTL_VFE;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3229
		/* Do not hardware filter VLANs in promisc mode */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3230
		e1000e_vlan_filter_disable(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3231
	} else {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3232
		if (netdev->flags & IFF_ALLMULTI) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3233
			rctl |= E1000_RCTL_MPE;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3234
			rctl &= ~E1000_RCTL_UPE;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3235
		} else {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3236
			rctl &= ~(E1000_RCTL_UPE | E1000_RCTL_MPE);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3237
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3238
		e1000e_vlan_filter_enable(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3239
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3240
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3241
	ew32(RCTL, rctl);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3242
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3243
	if (!netdev_mc_empty(netdev)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3244
		int i = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3245
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3246
		mta_list = kmalloc(netdev_mc_count(netdev) * 6, GFP_ATOMIC);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3247
		if (!mta_list)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3248
			return;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3249
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3250
		/* prepare a packed array of only addresses. */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3251
		netdev_for_each_mc_addr(ha, netdev)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3252
			memcpy(mta_list + (i++ * ETH_ALEN), ha->addr, ETH_ALEN);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3253
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3254
		e1000_update_mc_addr_list(hw, mta_list, i);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3255
		kfree(mta_list);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3256
	} else {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3257
		/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3258
		 * if we're called from probe, we might not have
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3259
		 * anything to do here, so clear out the list
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3260
		 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3261
		e1000_update_mc_addr_list(hw, NULL, 0);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3262
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3263
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3264
	if (netdev->features & NETIF_F_HW_VLAN_RX)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3265
		e1000e_vlan_strip_enable(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3266
	else
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3267
		e1000e_vlan_strip_disable(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3268
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3269
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3270
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3271
 * e1000_configure - configure the hardware for Rx and Tx
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3272
 * @adapter: private board structure
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3273
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3274
static void e1000_configure(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3275
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3276
	e1000_set_multi(adapter->netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3277
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3278
	e1000_restore_vlan(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3279
	e1000_init_manageability_pt(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3280
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3281
	e1000_configure_tx(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3282
	e1000_setup_rctl(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3283
	e1000_configure_rx(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3284
	if (adapter->ecdev) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3285
		adapter->alloc_rx_buf(adapter, adapter->rx_ring->count, GFP_KERNEL);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3286
	} else {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3287
		adapter->alloc_rx_buf(adapter, e1000_desc_unused(adapter->rx_ring),
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3288
			      	GFP_KERNEL);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3289
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3290
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3291
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3292
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3293
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3294
 * e1000e_power_up_phy - restore link in case the phy was powered down
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3295
 * @adapter: address of board private structure
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3296
 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3297
 * The phy may be powered down to save power and turn off link when the
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3298
 * driver is unloaded and wake on lan is not enabled (among others)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3299
 * *** this routine MUST be followed by a call to e1000e_reset ***
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3300
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3301
void e1000e_power_up_phy(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3302
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3303
	if (adapter->hw.phy.ops.power_up)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3304
		adapter->hw.phy.ops.power_up(&adapter->hw);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3305
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3306
	adapter->hw.mac.ops.setup_link(&adapter->hw);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3307
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3308
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3309
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3310
 * e1000_power_down_phy - Power down the PHY
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3311
 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3312
 * Power down the PHY so no link is implied when interface is down.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3313
 * The PHY cannot be powered down if management or WoL is active.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3314
 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3315
static void e1000_power_down_phy(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3316
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3317
	/* WoL is enabled */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3318
	if (adapter->wol)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3319
		return;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3320
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3321
	if (adapter->hw.phy.ops.power_down)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3322
		adapter->hw.phy.ops.power_down(&adapter->hw);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3323
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3324
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3325
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3326
 * e1000e_reset - bring the hardware into a known good state
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3327
 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3328
 * This function boots the hardware and enables some settings that
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3329
 * require a configuration cycle of the hardware - those cannot be
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3330
 * set/changed during runtime. After reset the device needs to be
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3331
 * properly configured for Rx, Tx etc.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3332
 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3333
void e1000e_reset(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3334
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3335
	struct e1000_mac_info *mac = &adapter->hw.mac;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3336
	struct e1000_fc_info *fc = &adapter->hw.fc;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3337
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3338
	u32 tx_space, min_tx_space, min_rx_space;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3339
	u32 pba = adapter->pba;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3340
	u16 hwm;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3341
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3342
	/* reset Packet Buffer Allocation to default */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3343
	ew32(PBA, pba);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3344
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3345
	if (adapter->max_frame_size > ETH_FRAME_LEN + ETH_FCS_LEN) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3346
		/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3347
		 * To maintain wire speed transmits, the Tx FIFO should be
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3348
		 * large enough to accommodate two full transmit packets,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3349
		 * rounded up to the next 1KB and expressed in KB.  Likewise,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3350
		 * the Rx FIFO should be large enough to accommodate at least
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3351
		 * one full receive packet and is similarly rounded up and
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3352
		 * expressed in KB.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3353
		 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3354
		pba = er32(PBA);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3355
		/* upper 16 bits has Tx packet buffer allocation size in KB */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3356
		tx_space = pba >> 16;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3357
		/* lower 16 bits has Rx packet buffer allocation size in KB */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3358
		pba &= 0xffff;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3359
		/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3360
		 * the Tx fifo also stores 16 bytes of information about the Tx
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3361
		 * but don't include ethernet FCS because hardware appends it
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3362
		 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3363
		min_tx_space = (adapter->max_frame_size +
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3364
				sizeof(struct e1000_tx_desc) -
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3365
				ETH_FCS_LEN) * 2;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3366
		min_tx_space = ALIGN(min_tx_space, 1024);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3367
		min_tx_space >>= 10;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3368
		/* software strips receive CRC, so leave room for it */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3369
		min_rx_space = adapter->max_frame_size;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3370
		min_rx_space = ALIGN(min_rx_space, 1024);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3371
		min_rx_space >>= 10;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3372
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3373
		/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3374
		 * If current Tx allocation is less than the min Tx FIFO size,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3375
		 * and the min Tx FIFO size is less than the current Rx FIFO
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3376
		 * allocation, take space away from current Rx allocation
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3377
		 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3378
		if ((tx_space < min_tx_space) &&
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3379
		    ((min_tx_space - tx_space) < pba)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3380
			pba -= min_tx_space - tx_space;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3381
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3382
			/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3383
			 * if short on Rx space, Rx wins and must trump Tx
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3384
			 * adjustment or use Early Receive if available
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3385
			 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3386
			if ((pba < min_rx_space) &&
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3387
			    (!(adapter->flags & FLAG_HAS_ERT)))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3388
				/* ERT enabled in e1000_configure_rx */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3389
				pba = min_rx_space;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3390
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3391
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3392
		ew32(PBA, pba);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3393
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3394
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3395
	/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3396
	 * flow control settings
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3397
	 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3398
	 * The high water mark must be low enough to fit one full frame
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3399
	 * (or the size used for early receive) above it in the Rx FIFO.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3400
	 * Set it to the lower of:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3401
	 * - 90% of the Rx FIFO size, and
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3402
	 * - the full Rx FIFO size minus the early receive size (for parts
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3403
	 *   with ERT support assuming ERT set to E1000_ERT_2048), or
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3404
	 * - the full Rx FIFO size minus one full frame
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3405
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3406
	if (adapter->flags & FLAG_DISABLE_FC_PAUSE_TIME)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3407
		fc->pause_time = 0xFFFF;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3408
	else
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3409
		fc->pause_time = E1000_FC_PAUSE_TIME;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3410
	fc->send_xon = 1;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3411
	fc->current_mode = fc->requested_mode;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3412
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3413
	switch (hw->mac.type) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3414
	default:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3415
		if ((adapter->flags & FLAG_HAS_ERT) &&
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3416
		    (adapter->netdev->mtu > ETH_DATA_LEN))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3417
			hwm = min(((pba << 10) * 9 / 10),
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3418
				  ((pba << 10) - (E1000_ERT_2048 << 3)));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3419
		else
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3420
			hwm = min(((pba << 10) * 9 / 10),
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3421
				  ((pba << 10) - adapter->max_frame_size));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3422
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3423
		fc->high_water = hwm & E1000_FCRTH_RTH; /* 8-byte granularity */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3424
		fc->low_water = fc->high_water - 8;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3425
		break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3426
	case e1000_pchlan:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3427
		/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3428
		 * Workaround PCH LOM adapter hangs with certain network
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3429
		 * loads.  If hangs persist, try disabling Tx flow control.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3430
		 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3431
		if (adapter->netdev->mtu > ETH_DATA_LEN) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3432
			fc->high_water = 0x3500;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3433
			fc->low_water  = 0x1500;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3434
		} else {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3435
			fc->high_water = 0x5000;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3436
			fc->low_water  = 0x3000;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3437
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3438
		fc->refresh_time = 0x1000;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3439
		break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3440
	case e1000_pch2lan:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3441
		fc->high_water = 0x05C20;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3442
		fc->low_water = 0x05048;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3443
		fc->pause_time = 0x0650;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3444
		fc->refresh_time = 0x0400;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3445
		if (adapter->netdev->mtu > ETH_DATA_LEN) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3446
			pba = 14;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3447
			ew32(PBA, pba);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3448
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3449
		break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3450
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3451
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3452
	/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3453
	 * Disable Adaptive Interrupt Moderation if 2 full packets cannot
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3454
	 * fit in receive buffer and early-receive not supported.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3455
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3456
	if (adapter->itr_setting & 0x3) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3457
		if (((adapter->max_frame_size * 2) > (pba << 10)) &&
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3458
		    !(adapter->flags & FLAG_HAS_ERT)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3459
			if (!(adapter->flags2 & FLAG2_DISABLE_AIM)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3460
				dev_info(&adapter->pdev->dev,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3461
					"Interrupt Throttle Rate turned off\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3462
				adapter->flags2 |= FLAG2_DISABLE_AIM;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3463
				ew32(ITR, 0);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3464
			}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3465
		} else if (adapter->flags2 & FLAG2_DISABLE_AIM) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3466
			dev_info(&adapter->pdev->dev,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3467
				 "Interrupt Throttle Rate turned on\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3468
			adapter->flags2 &= ~FLAG2_DISABLE_AIM;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3469
			adapter->itr = 20000;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3470
			ew32(ITR, 1000000000 / (adapter->itr * 256));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3471
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3472
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3473
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3474
	/* Allow time for pending master requests to run */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3475
	mac->ops.reset_hw(hw);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3476
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3477
	/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3478
	 * For parts with AMT enabled, let the firmware know
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3479
	 * that the network interface is in control
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3480
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3481
	if (adapter->flags & FLAG_HAS_AMT)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3482
		e1000e_get_hw_control(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3483
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3484
	ew32(WUC, 0);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3485
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3486
	if (mac->ops.init_hw(hw))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3487
		e_err("Hardware Error\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3488
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3489
	e1000_update_mng_vlan(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3490
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3491
	/* Enable h/w to recognize an 802.1Q VLAN Ethernet packet */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3492
	ew32(VET, ETH_P_8021Q);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3493
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3494
	e1000e_reset_adaptive(hw);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3495
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3496
	if (!netif_running(adapter->netdev) &&
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3497
	    !test_bit(__E1000_TESTING, &adapter->state)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3498
		e1000_power_down_phy(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3499
		return;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3500
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3501
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3502
	e1000_get_phy_info(hw);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3503
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3504
	if ((adapter->flags & FLAG_HAS_SMART_POWER_DOWN) &&
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3505
	    !(adapter->flags & FLAG_SMART_POWER_DOWN)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3506
		u16 phy_data = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3507
		/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3508
		 * speed up time to link by disabling smart power down, ignore
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3509
		 * the return value of this function because there is nothing
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3510
		 * different we would do if it failed
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3511
		 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3512
		e1e_rphy(hw, IGP02E1000_PHY_POWER_MGMT, &phy_data);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3513
		phy_data &= ~IGP02E1000_PM_SPD;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3514
		e1e_wphy(hw, IGP02E1000_PHY_POWER_MGMT, phy_data);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3515
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3516
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3517
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3518
int e1000e_up(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3519
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3520
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3521
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3522
	/* hardware has been reset, we need to reload some things */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3523
	e1000_configure(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3524
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3525
	clear_bit(__E1000_DOWN, &adapter->state);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3526
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3527
	if (!adapter->ecdev) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3528
		napi_enable(&adapter->napi);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3529
	}
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  3530
2406
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3531
	if (adapter->msix_entries)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3532
		e1000_configure_msix(adapter);
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  3533
2406
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3534
	if (!adapter->ecdev) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3535
		e1000_irq_enable(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3536
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  3537
		netif_start_queue(adapter->netdev);
2406
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3538
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3539
		/* fire a link change interrupt to start the watchdog */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3540
		if (adapter->msix_entries)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3541
			ew32(ICS, E1000_ICS_LSC | E1000_ICR_OTHER);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3542
		else
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3543
			ew32(ICS, E1000_ICS_LSC);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3544
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3545
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3546
	return 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3547
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3548
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3549
static void e1000e_flush_descriptors(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3550
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3551
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3552
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3553
	if (!(adapter->flags2 & FLAG2_DMA_BURST))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3554
		return;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3555
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3556
	/* flush pending descriptor writebacks to memory */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3557
	ew32(TIDV, adapter->tx_int_delay | E1000_TIDV_FPD);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3558
	ew32(RDTR, adapter->rx_int_delay | E1000_RDTR_FPD);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3559
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3560
	/* execute the writes immediately */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3561
	e1e_flush();
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3562
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3563
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3564
static void e1000e_update_stats(struct e1000_adapter *adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3565
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3566
void e1000e_down(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3567
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3568
	struct net_device *netdev = adapter->netdev;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3569
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3570
	u32 tctl, rctl;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3571
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3572
	/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3573
	 * signal that we're down so the interrupt handler does not
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3574
	 * reschedule our watchdog timer
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3575
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3576
	set_bit(__E1000_DOWN, &adapter->state);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3577
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3578
	/* disable receives in the hardware */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3579
	rctl = er32(RCTL);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3580
	if (!(adapter->flags2 & FLAG2_NO_DISABLE_RX))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3581
		ew32(RCTL, rctl & ~E1000_RCTL_EN);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3582
	/* flush and sleep below */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3583
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  3584
	if (!adapter->ecdev)
2406
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3585
		netif_stop_queue(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3586
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3587
	/* disable transmits in the hardware */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3588
	tctl = er32(TCTL);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3589
	tctl &= ~E1000_TCTL_EN;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3590
	ew32(TCTL, tctl);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3591
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3592
	/* flush both disables and wait for them to finish */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3593
	e1e_flush();
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3594
	usleep_range(10000, 20000);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3595
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3596
	if (!adapter->ecdev) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3597
		napi_disable(&adapter->napi);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3598
		e1000_irq_disable(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3599
		del_timer_sync(&adapter->watchdog_timer);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3600
		del_timer_sync(&adapter->phy_info_timer);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3601
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3602
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3603
	if (adapter->ecdev) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3604
		ecdev_set_link(adapter->ecdev, 0);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3605
	} else {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3606
		netif_carrier_off(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3607
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3608
	spin_lock(&adapter->stats64_lock);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3609
	e1000e_update_stats(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3610
	spin_unlock(&adapter->stats64_lock);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3611
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3612
	e1000e_flush_descriptors(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3613
	e1000_clean_tx_ring(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3614
	e1000_clean_rx_ring(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3615
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3616
	adapter->link_speed = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3617
	adapter->link_duplex = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3618
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3619
	if (!pci_channel_offline(adapter->pdev))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3620
		e1000e_reset(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3621
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3622
	/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3623
	 * TODO: for power management, we could drop the link and
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3624
	 * pci_disable_device here.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3625
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3626
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3627
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3628
void e1000e_reinit_locked(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3629
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3630
	might_sleep();
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3631
	while (test_and_set_bit(__E1000_RESETTING, &adapter->state))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3632
		usleep_range(1000, 2000);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3633
	e1000e_down(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3634
	e1000e_up(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3635
	clear_bit(__E1000_RESETTING, &adapter->state);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3636
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3637
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3638
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3639
 * e1000_sw_init - Initialize general software structures (struct e1000_adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3640
 * @adapter: board private structure to initialize
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3641
 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3642
 * e1000_sw_init initializes the Adapter private data structure.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3643
 * Fields are initialized based on PCI device information and
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3644
 * OS network device settings (MTU size).
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3645
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3646
static int __devinit e1000_sw_init(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3647
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3648
	struct net_device *netdev = adapter->netdev;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3649
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3650
	adapter->rx_buffer_len = ETH_FRAME_LEN + VLAN_HLEN + ETH_FCS_LEN;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3651
	adapter->rx_ps_bsize0 = 128;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3652
	adapter->max_frame_size = netdev->mtu + ETH_HLEN + ETH_FCS_LEN;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3653
	adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3654
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3655
	spin_lock_init(&adapter->stats64_lock);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3656
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3657
	e1000e_set_interrupt_capability(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3658
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3659
	if (e1000_alloc_queues(adapter))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3660
		return -ENOMEM;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3661
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3662
	/* Explicitly disable IRQ since the NIC can be in any state. */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3663
	e1000_irq_disable(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3664
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3665
	set_bit(__E1000_DOWN, &adapter->state);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3666
	return 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3667
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3668
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3669
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3670
 * e1000_intr_msi_test - Interrupt Handler
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3671
 * @irq: interrupt number
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3672
 * @data: pointer to a network interface device structure
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3673
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3674
static irqreturn_t e1000_intr_msi_test(int irq, void *data)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3675
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3676
	struct net_device *netdev = data;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3677
	struct e1000_adapter *adapter = netdev_priv(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3678
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3679
	u32 icr = er32(ICR);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3680
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3681
	e_dbg("icr is %08X\n", icr);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3682
	if (icr & E1000_ICR_RXSEQ) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3683
		adapter->flags &= ~FLAG_MSI_TEST_FAILED;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3684
		wmb();
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3685
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3686
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3687
	return IRQ_HANDLED;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3688
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3689
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3690
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3691
 * e1000_test_msi_interrupt - Returns 0 for successful test
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3692
 * @adapter: board private struct
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3693
 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3694
 * code flow taken from tg3.c
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3695
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3696
static int e1000_test_msi_interrupt(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3697
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3698
	struct net_device *netdev = adapter->netdev;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3699
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3700
	int err;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3701
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3702
	/* poll_enable hasn't been called yet, so don't need disable */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3703
	/* clear any pending events */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3704
	er32(ICR);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3705
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3706
	/* free the real vector and request a test handler */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3707
	e1000_free_irq(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3708
	e1000e_reset_interrupt_capability(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3709
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3710
	/* Assume that the test fails, if it succeeds then the test
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3711
	 * MSI irq handler will unset this flag */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3712
	adapter->flags |= FLAG_MSI_TEST_FAILED;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3713
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3714
	err = pci_enable_msi(adapter->pdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3715
	if (err)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3716
		goto msi_test_failed;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3717
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3718
	err = request_irq(adapter->pdev->irq, e1000_intr_msi_test, 0,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3719
			  netdev->name, netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3720
	if (err) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3721
		pci_disable_msi(adapter->pdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3722
		goto msi_test_failed;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3723
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3724
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3725
	wmb();
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3726
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3727
	e1000_irq_enable(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3728
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3729
	/* fire an unusual interrupt on the test handler */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3730
	ew32(ICS, E1000_ICS_RXSEQ);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3731
	e1e_flush();
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3732
	msleep(50);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3733
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3734
	e1000_irq_disable(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3735
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3736
	rmb();
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3737
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3738
	if (adapter->flags & FLAG_MSI_TEST_FAILED) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3739
		adapter->int_mode = E1000E_INT_MODE_LEGACY;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3740
		e_info("MSI interrupt test failed, using legacy interrupt.\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3741
	} else
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3742
		e_dbg("MSI interrupt test succeeded!\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3743
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3744
	free_irq(adapter->pdev->irq, netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3745
	pci_disable_msi(adapter->pdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3746
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3747
msi_test_failed:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3748
	e1000e_set_interrupt_capability(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3749
	return e1000_request_irq(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3750
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3751
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3752
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3753
 * e1000_test_msi - Returns 0 if MSI test succeeds or INTx mode is restored
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3754
 * @adapter: board private struct
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3755
 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3756
 * code flow taken from tg3.c, called with e1000 interrupts disabled.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3757
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3758
static int e1000_test_msi(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3759
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3760
	int err;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3761
	u16 pci_cmd;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3762
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3763
	if (!(adapter->flags & FLAG_MSI_ENABLED))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3764
		return 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3765
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3766
	/* disable SERR in case the MSI write causes a master abort */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3767
	pci_read_config_word(adapter->pdev, PCI_COMMAND, &pci_cmd);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3768
	if (pci_cmd & PCI_COMMAND_SERR)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3769
		pci_write_config_word(adapter->pdev, PCI_COMMAND,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3770
				      pci_cmd & ~PCI_COMMAND_SERR);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3771
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3772
	err = e1000_test_msi_interrupt(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3773
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3774
	/* re-enable SERR */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3775
	if (pci_cmd & PCI_COMMAND_SERR) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3776
		pci_read_config_word(adapter->pdev, PCI_COMMAND, &pci_cmd);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3777
		pci_cmd |= PCI_COMMAND_SERR;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3778
		pci_write_config_word(adapter->pdev, PCI_COMMAND, pci_cmd);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3779
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3780
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3781
	return err;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3782
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3783
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3784
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3785
 * e1000_open - Called when a network interface is made active
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3786
 * @netdev: network interface device structure
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3787
 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3788
 * Returns 0 on success, negative value on failure
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3789
 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3790
 * The open entry point is called when a network interface is made
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3791
 * active by the system (IFF_UP).  At this point all resources needed
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3792
 * for transmit and receive operations are allocated, the interrupt
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3793
 * handler is registered with the OS, the watchdog timer is started,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3794
 * and the stack is notified that the interface is ready.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3795
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3796
static int e1000_open(struct net_device *netdev)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3797
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3798
	struct e1000_adapter *adapter = netdev_priv(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3799
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3800
	struct pci_dev *pdev = adapter->pdev;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3801
	int err;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3802
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3803
	/* disallow open during test */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3804
	if (test_bit(__E1000_TESTING, &adapter->state))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3805
		return -EBUSY;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3806
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3807
	pm_runtime_get_sync(&pdev->dev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3808
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3809
	if (adapter->ecdev) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3810
		ecdev_set_link(adapter->ecdev, 0);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3811
	} else {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3812
		netif_carrier_off(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3813
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3814
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3815
	/* allocate transmit descriptors */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3816
	err = e1000e_setup_tx_resources(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3817
	if (err)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3818
		goto err_setup_tx;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3819
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3820
	/* allocate receive descriptors */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3821
	err = e1000e_setup_rx_resources(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3822
	if (err)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3823
		goto err_setup_rx;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3824
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3825
	/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3826
	 * If AMT is enabled, let the firmware know that the network
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3827
	 * interface is now open and reset the part to a known state.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3828
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3829
	if (adapter->flags & FLAG_HAS_AMT) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3830
		e1000e_get_hw_control(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3831
		e1000e_reset(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3832
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3833
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3834
	e1000e_power_up_phy(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3835
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3836
	adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3837
	if ((adapter->hw.mng_cookie.status &
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3838
	     E1000_MNG_DHCP_COOKIE_STATUS_VLAN))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3839
		e1000_update_mng_vlan(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3840
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3841
	/* DMA latency requirement to workaround early-receive/jumbo issue */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3842
	if ((adapter->flags & FLAG_HAS_ERT) ||
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3843
	    (adapter->hw.mac.type == e1000_pch2lan))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3844
		pm_qos_add_request(&adapter->netdev->pm_qos_req,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3845
				   PM_QOS_CPU_DMA_LATENCY,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3846
				   PM_QOS_DEFAULT_VALUE);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3847
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3848
	/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3849
	 * before we allocate an interrupt, we must be ready to handle it.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3850
	 * Setting DEBUG_SHIRQ in the kernel makes it fire an interrupt
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3851
	 * as soon as we call pci_request_irq, so we have to setup our
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3852
	 * clean_rx handler before we do so.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3853
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3854
	e1000_configure(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3855
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3856
	err = e1000_request_irq(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3857
	if (err)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3858
		goto err_req_irq;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3859
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3860
	/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3861
	 * Work around PCIe errata with MSI interrupts causing some chipsets to
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3862
	 * ignore e1000e MSI messages, which means we need to test our MSI
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3863
	 * interrupt now
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3864
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3865
	if (adapter->int_mode != E1000E_INT_MODE_LEGACY) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3866
		err = e1000_test_msi(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3867
		if (err) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3868
			e_err("Interrupt allocation failed\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3869
			goto err_req_irq;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3870
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3871
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3872
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3873
	/* From here on the code is the same as e1000e_up() */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3874
	clear_bit(__E1000_DOWN, &adapter->state);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3875
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3876
	if (!adapter->ecdev) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3877
		napi_enable(&adapter->napi);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3878
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3879
		e1000_irq_enable(adapter);
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  3880
	}
2406
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3881
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3882
	adapter->tx_hang_recheck = false;
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  3883
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  3884
	if (!adapter->ecdev) {
2406
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3885
		netif_start_queue(netdev);
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  3886
	}
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  3887
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  3888
	adapter->idle_check = true;
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  3889
	pm_runtime_put(&pdev->dev);
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  3890
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  3891
	/* fire a link status change interrupt to start the watchdog */
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  3892
	if (adapter->msix_entries)
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  3893
		ew32(ICS, E1000_ICS_LSC | E1000_ICR_OTHER);
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  3894
	else
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  3895
		ew32(ICS, E1000_ICS_LSC);
2406
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3896
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3897
	return 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3898
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3899
err_req_irq:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3900
	e1000e_release_hw_control(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3901
	e1000_power_down_phy(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3902
	e1000e_free_rx_resources(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3903
err_setup_rx:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3904
	e1000e_free_tx_resources(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3905
err_setup_tx:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3906
	e1000e_reset(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3907
	pm_runtime_put_sync(&pdev->dev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3908
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3909
	return err;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3910
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3911
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3912
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3913
 * e1000_close - Disables a network interface
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3914
 * @netdev: network interface device structure
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3915
 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3916
 * Returns 0, this is not allowed to fail
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3917
 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3918
 * The close entry point is called when an interface is de-activated
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3919
 * by the OS.  The hardware is still under the drivers control, but
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3920
 * needs to be disabled.  A global MAC reset is issued to stop the
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3921
 * hardware, and all transmit and receive resources are freed.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3922
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3923
static int e1000_close(struct net_device *netdev)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3924
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3925
	struct e1000_adapter *adapter = netdev_priv(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3926
	struct pci_dev *pdev = adapter->pdev;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3927
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3928
	WARN_ON(test_bit(__E1000_RESETTING, &adapter->state));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3929
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3930
	pm_runtime_get_sync(&pdev->dev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3931
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3932
	if (!test_bit(__E1000_DOWN, &adapter->state)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3933
		e1000e_down(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3934
		e1000_free_irq(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3935
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3936
	e1000_power_down_phy(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3937
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3938
	e1000e_free_tx_resources(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3939
	e1000e_free_rx_resources(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3940
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3941
	/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3942
	 * kill manageability vlan ID if supported, but not if a vlan with
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3943
	 * the same ID is registered on the host OS (let 8021q kill it)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3944
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3945
	if (adapter->hw.mng_cookie.status &
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3946
	    E1000_MNG_DHCP_COOKIE_STATUS_VLAN)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3947
		e1000_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3948
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3949
	/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3950
	 * If AMT is enabled, let the firmware know that the network
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3951
	 * interface is now closed
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3952
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3953
	if ((adapter->flags & FLAG_HAS_AMT) &&
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3954
	    !test_bit(__E1000_TESTING, &adapter->state))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3955
		e1000e_release_hw_control(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3956
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3957
	if ((adapter->flags & FLAG_HAS_ERT) ||
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3958
	    (adapter->hw.mac.type == e1000_pch2lan))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3959
		pm_qos_remove_request(&adapter->netdev->pm_qos_req);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3960
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3961
	pm_runtime_put_sync(&pdev->dev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3962
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3963
	return 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3964
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3965
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3966
 * e1000_set_mac - Change the Ethernet Address of the NIC
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3967
 * @netdev: network interface device structure
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3968
 * @p: pointer to an address structure
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3969
 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3970
 * Returns 0 on success, negative on failure
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3971
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3972
static int e1000_set_mac(struct net_device *netdev, void *p)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3973
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3974
	struct e1000_adapter *adapter = netdev_priv(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3975
	struct sockaddr *addr = p;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3976
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3977
	if (!is_valid_ether_addr(addr->sa_data))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3978
		return -EADDRNOTAVAIL;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3979
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3980
	memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3981
	memcpy(adapter->hw.mac.addr, addr->sa_data, netdev->addr_len);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3982
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3983
	e1000e_rar_set(&adapter->hw, adapter->hw.mac.addr, 0);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3984
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3985
	if (adapter->flags & FLAG_RESET_OVERWRITES_LAA) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3986
		/* activate the work around */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3987
		e1000e_set_laa_state_82571(&adapter->hw, 1);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3988
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3989
		/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3990
		 * Hold a copy of the LAA in RAR[14] This is done so that
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3991
		 * between the time RAR[0] gets clobbered  and the time it
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3992
		 * gets fixed (in e1000_watchdog), the actual LAA is in one
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3993
		 * of the RARs and no incoming packets directed to this port
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3994
		 * are dropped. Eventually the LAA will be in RAR[0] and
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3995
		 * RAR[14]
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3996
		 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3997
		e1000e_rar_set(&adapter->hw,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3998
			      adapter->hw.mac.addr,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3999
			      adapter->hw.mac.rar_entry_count - 1);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4000
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4001
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4002
	return 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4003
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4004
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4005
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4006
 * e1000e_update_phy_task - work thread to update phy
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4007
 * @work: pointer to our work struct
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4008
 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4009
 * this worker thread exists because we must acquire a
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4010
 * semaphore to read the phy, which we could msleep while
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4011
 * waiting for it, and we can't msleep in a timer.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4012
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4013
static void e1000e_update_phy_task(struct work_struct *work)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4014
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4015
	struct e1000_adapter *adapter = container_of(work,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4016
					struct e1000_adapter, update_phy_task);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4017
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4018
	if (test_bit(__E1000_DOWN, &adapter->state))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4019
		return;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4020
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4021
	e1000_get_phy_info(&adapter->hw);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4022
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4023
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4024
/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4025
 * Need to wait a few seconds after link up to get diagnostic information from
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4026
 * the phy
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4027
 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4028
static void e1000_update_phy_info(unsigned long data)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4029
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4030
	struct e1000_adapter *adapter = (struct e1000_adapter *) data;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4031
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4032
	if (test_bit(__E1000_DOWN, &adapter->state))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4033
		return;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4034
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4035
	schedule_work(&adapter->update_phy_task);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4036
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4037
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4038
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4039
 * e1000e_update_phy_stats - Update the PHY statistics counters
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4040
 * @adapter: board private structure
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4041
 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4042
 * Read/clear the upper 16-bit PHY registers and read/accumulate lower
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4043
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4044
static void e1000e_update_phy_stats(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4045
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4046
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4047
	s32 ret_val;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4048
	u16 phy_data;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4049
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4050
	ret_val = hw->phy.ops.acquire(hw);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4051
	if (ret_val)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4052
		return;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4053
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4054
	/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4055
	 * A page set is expensive so check if already on desired page.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4056
	 * If not, set to the page with the PHY status registers.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4057
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4058
	hw->phy.addr = 1;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4059
	ret_val = e1000e_read_phy_reg_mdic(hw, IGP01E1000_PHY_PAGE_SELECT,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4060
					   &phy_data);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4061
	if (ret_val)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4062
		goto release;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4063
	if (phy_data != (HV_STATS_PAGE << IGP_PAGE_SHIFT)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4064
		ret_val = hw->phy.ops.set_page(hw,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4065
					       HV_STATS_PAGE << IGP_PAGE_SHIFT);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4066
		if (ret_val)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4067
			goto release;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4068
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4069
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4070
	/* Single Collision Count */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4071
	hw->phy.ops.read_reg_page(hw, HV_SCC_UPPER, &phy_data);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4072
	ret_val = hw->phy.ops.read_reg_page(hw, HV_SCC_LOWER, &phy_data);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4073
	if (!ret_val)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4074
		adapter->stats.scc += phy_data;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4075
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4076
	/* Excessive Collision Count */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4077
	hw->phy.ops.read_reg_page(hw, HV_ECOL_UPPER, &phy_data);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4078
	ret_val = hw->phy.ops.read_reg_page(hw, HV_ECOL_LOWER, &phy_data);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4079
	if (!ret_val)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4080
		adapter->stats.ecol += phy_data;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4081
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4082
	/* Multiple Collision Count */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4083
	hw->phy.ops.read_reg_page(hw, HV_MCC_UPPER, &phy_data);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4084
	ret_val = hw->phy.ops.read_reg_page(hw, HV_MCC_LOWER, &phy_data);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4085
	if (!ret_val)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4086
		adapter->stats.mcc += phy_data;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4087
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4088
	/* Late Collision Count */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4089
	hw->phy.ops.read_reg_page(hw, HV_LATECOL_UPPER, &phy_data);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4090
	ret_val = hw->phy.ops.read_reg_page(hw, HV_LATECOL_LOWER, &phy_data);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4091
	if (!ret_val)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4092
		adapter->stats.latecol += phy_data;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4093
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4094
	/* Collision Count - also used for adaptive IFS */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4095
	hw->phy.ops.read_reg_page(hw, HV_COLC_UPPER, &phy_data);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4096
	ret_val = hw->phy.ops.read_reg_page(hw, HV_COLC_LOWER, &phy_data);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4097
	if (!ret_val)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4098
		hw->mac.collision_delta = phy_data;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4099
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4100
	/* Defer Count */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4101
	hw->phy.ops.read_reg_page(hw, HV_DC_UPPER, &phy_data);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4102
	ret_val = hw->phy.ops.read_reg_page(hw, HV_DC_LOWER, &phy_data);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4103
	if (!ret_val)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4104
		adapter->stats.dc += phy_data;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4105
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4106
	/* Transmit with no CRS */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4107
	hw->phy.ops.read_reg_page(hw, HV_TNCRS_UPPER, &phy_data);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4108
	ret_val = hw->phy.ops.read_reg_page(hw, HV_TNCRS_LOWER, &phy_data);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4109
	if (!ret_val)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4110
		adapter->stats.tncrs += phy_data;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4111
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4112
release:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4113
	hw->phy.ops.release(hw);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4114
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4115
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4116
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4117
 * e1000e_update_stats - Update the board statistics counters
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4118
 * @adapter: board private structure
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4119
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4120
static void e1000e_update_stats(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4121
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4122
	struct net_device *netdev = adapter->netdev;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4123
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4124
	struct pci_dev *pdev = adapter->pdev;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4125
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4126
	/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4127
	 * Prevent stats update while adapter is being reset, or if the pci
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4128
	 * connection is down.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4129
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4130
	if (adapter->link_speed == 0)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4131
		return;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4132
	if (pci_channel_offline(pdev))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4133
		return;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4134
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4135
	adapter->stats.crcerrs += er32(CRCERRS);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4136
	adapter->stats.gprc += er32(GPRC);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4137
	adapter->stats.gorc += er32(GORCL);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4138
	er32(GORCH); /* Clear gorc */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4139
	adapter->stats.bprc += er32(BPRC);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4140
	adapter->stats.mprc += er32(MPRC);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4141
	adapter->stats.roc += er32(ROC);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4142
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4143
	adapter->stats.mpc += er32(MPC);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4144
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4145
	/* Half-duplex statistics */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4146
	if (adapter->link_duplex == HALF_DUPLEX) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4147
		if (adapter->flags2 & FLAG2_HAS_PHY_STATS) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4148
			e1000e_update_phy_stats(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4149
		} else {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4150
			adapter->stats.scc += er32(SCC);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4151
			adapter->stats.ecol += er32(ECOL);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4152
			adapter->stats.mcc += er32(MCC);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4153
			adapter->stats.latecol += er32(LATECOL);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4154
			adapter->stats.dc += er32(DC);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4155
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4156
			hw->mac.collision_delta = er32(COLC);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4157
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4158
			if ((hw->mac.type != e1000_82574) &&
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4159
			    (hw->mac.type != e1000_82583))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4160
				adapter->stats.tncrs += er32(TNCRS);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4161
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4162
		adapter->stats.colc += hw->mac.collision_delta;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4163
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4164
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4165
	adapter->stats.xonrxc += er32(XONRXC);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4166
	adapter->stats.xontxc += er32(XONTXC);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4167
	adapter->stats.xoffrxc += er32(XOFFRXC);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4168
	adapter->stats.xofftxc += er32(XOFFTXC);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4169
	adapter->stats.gptc += er32(GPTC);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4170
	adapter->stats.gotc += er32(GOTCL);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4171
	er32(GOTCH); /* Clear gotc */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4172
	adapter->stats.rnbc += er32(RNBC);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4173
	adapter->stats.ruc += er32(RUC);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4174
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4175
	adapter->stats.mptc += er32(MPTC);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4176
	adapter->stats.bptc += er32(BPTC);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4177
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4178
	/* used for adaptive IFS */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4179
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4180
	hw->mac.tx_packet_delta = er32(TPT);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4181
	adapter->stats.tpt += hw->mac.tx_packet_delta;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4182
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4183
	adapter->stats.algnerrc += er32(ALGNERRC);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4184
	adapter->stats.rxerrc += er32(RXERRC);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4185
	adapter->stats.cexterr += er32(CEXTERR);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4186
	adapter->stats.tsctc += er32(TSCTC);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4187
	adapter->stats.tsctfc += er32(TSCTFC);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4188
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4189
	/* Fill out the OS statistics structure */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4190
	netdev->stats.multicast = adapter->stats.mprc;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4191
	netdev->stats.collisions = adapter->stats.colc;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4192
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4193
	/* Rx Errors */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4194
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4195
	/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4196
	 * RLEC on some newer hardware can be incorrect so build
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4197
	 * our own version based on RUC and ROC
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4198
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4199
	netdev->stats.rx_errors = adapter->stats.rxerrc +
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4200
		adapter->stats.crcerrs + adapter->stats.algnerrc +
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4201
		adapter->stats.ruc + adapter->stats.roc +
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4202
		adapter->stats.cexterr;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4203
	netdev->stats.rx_length_errors = adapter->stats.ruc +
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4204
					      adapter->stats.roc;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4205
	netdev->stats.rx_crc_errors = adapter->stats.crcerrs;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4206
	netdev->stats.rx_frame_errors = adapter->stats.algnerrc;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4207
	netdev->stats.rx_missed_errors = adapter->stats.mpc;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4208
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4209
	/* Tx Errors */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4210
	netdev->stats.tx_errors = adapter->stats.ecol +
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4211
				       adapter->stats.latecol;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4212
	netdev->stats.tx_aborted_errors = adapter->stats.ecol;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4213
	netdev->stats.tx_window_errors = adapter->stats.latecol;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4214
	netdev->stats.tx_carrier_errors = adapter->stats.tncrs;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4215
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4216
	/* Tx Dropped needs to be maintained elsewhere */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4217
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4218
	/* Management Stats */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4219
	adapter->stats.mgptc += er32(MGTPTC);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4220
	adapter->stats.mgprc += er32(MGTPRC);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4221
	adapter->stats.mgpdc += er32(MGTPDC);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4222
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4223
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4224
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4225
 * e1000_phy_read_status - Update the PHY register status snapshot
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4226
 * @adapter: board private structure
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4227
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4228
static void e1000_phy_read_status(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4229
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4230
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4231
	struct e1000_phy_regs *phy = &adapter->phy_regs;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4232
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4233
	if ((er32(STATUS) & E1000_STATUS_LU) &&
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4234
	    (adapter->hw.phy.media_type == e1000_media_type_copper)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4235
		int ret_val;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4236
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4237
		ret_val  = e1e_rphy(hw, PHY_CONTROL, &phy->bmcr);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4238
		ret_val |= e1e_rphy(hw, PHY_STATUS, &phy->bmsr);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4239
		ret_val |= e1e_rphy(hw, PHY_AUTONEG_ADV, &phy->advertise);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4240
		ret_val |= e1e_rphy(hw, PHY_LP_ABILITY, &phy->lpa);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4241
		ret_val |= e1e_rphy(hw, PHY_AUTONEG_EXP, &phy->expansion);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4242
		ret_val |= e1e_rphy(hw, PHY_1000T_CTRL, &phy->ctrl1000);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4243
		ret_val |= e1e_rphy(hw, PHY_1000T_STATUS, &phy->stat1000);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4244
		ret_val |= e1e_rphy(hw, PHY_EXT_STATUS, &phy->estatus);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4245
		if (ret_val)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4246
			e_warn("Error reading PHY register\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4247
	} else {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4248
		/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4249
		 * Do not read PHY registers if link is not up
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4250
		 * Set values to typical power-on defaults
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4251
		 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4252
		phy->bmcr = (BMCR_SPEED1000 | BMCR_ANENABLE | BMCR_FULLDPLX);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4253
		phy->bmsr = (BMSR_100FULL | BMSR_100HALF | BMSR_10FULL |
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4254
			     BMSR_10HALF | BMSR_ESTATEN | BMSR_ANEGCAPABLE |
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4255
			     BMSR_ERCAP);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4256
		phy->advertise = (ADVERTISE_PAUSE_ASYM | ADVERTISE_PAUSE_CAP |
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4257
				  ADVERTISE_ALL | ADVERTISE_CSMA);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4258
		phy->lpa = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4259
		phy->expansion = EXPANSION_ENABLENPAGE;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4260
		phy->ctrl1000 = ADVERTISE_1000FULL;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4261
		phy->stat1000 = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4262
		phy->estatus = (ESTATUS_1000_TFULL | ESTATUS_1000_THALF);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4263
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4264
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4265
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4266
static void e1000_print_link_info(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4267
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4268
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4269
	u32 ctrl = er32(CTRL);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4270
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4271
	/* Link status message must follow this format for user tools */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4272
	printk(KERN_INFO "e1000e: %s NIC Link is Up %d Mbps %s, "
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4273
	       "Flow Control: %s\n",
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4274
	       adapter->netdev->name,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4275
	       adapter->link_speed,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4276
	       (adapter->link_duplex == FULL_DUPLEX) ?
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4277
	       "Full Duplex" : "Half Duplex",
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4278
	       ((ctrl & E1000_CTRL_TFCE) && (ctrl & E1000_CTRL_RFCE)) ?
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4279
	       "Rx/Tx" :
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4280
	       ((ctrl & E1000_CTRL_RFCE) ? "Rx" :
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4281
		((ctrl & E1000_CTRL_TFCE) ? "Tx" : "None")));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4282
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4283
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4284
static bool e1000e_has_link(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4285
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4286
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4287
	bool link_active = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4288
	s32 ret_val = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4289
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4290
	/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4291
	 * get_link_status is set on LSC (link status) interrupt or
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4292
	 * Rx sequence error interrupt.  get_link_status will stay
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4293
	 * false until the check_for_link establishes link
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4294
	 * for copper adapters ONLY
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4295
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4296
	switch (hw->phy.media_type) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4297
	case e1000_media_type_copper:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4298
		if (hw->mac.get_link_status) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4299
			ret_val = hw->mac.ops.check_for_link(hw);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4300
			link_active = !hw->mac.get_link_status;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4301
		} else {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4302
			link_active = 1;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4303
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4304
		break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4305
	case e1000_media_type_fiber:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4306
		ret_val = hw->mac.ops.check_for_link(hw);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4307
		link_active = !!(er32(STATUS) & E1000_STATUS_LU);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4308
		break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4309
	case e1000_media_type_internal_serdes:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4310
		ret_val = hw->mac.ops.check_for_link(hw);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4311
		link_active = adapter->hw.mac.serdes_has_link;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4312
		break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4313
	default:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4314
	case e1000_media_type_unknown:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4315
		break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4316
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4317
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4318
	if ((ret_val == E1000_ERR_PHY) && (hw->phy.type == e1000_phy_igp_3) &&
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4319
	    (er32(CTRL) & E1000_PHY_CTRL_GBE_DISABLE)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4320
		/* See e1000_kmrn_lock_loss_workaround_ich8lan() */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4321
		e_info("Gigabit has been disabled, downgrading speed\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4322
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4323
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4324
	return link_active;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4325
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4326
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4327
static void e1000e_enable_receives(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4328
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4329
	/* make sure the receive unit is started */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4330
	if ((adapter->flags & FLAG_RX_NEEDS_RESTART) &&
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4331
	    (adapter->flags & FLAG_RX_RESTART_NOW)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4332
		struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4333
		u32 rctl = er32(RCTL);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4334
		ew32(RCTL, rctl | E1000_RCTL_EN);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4335
		adapter->flags &= ~FLAG_RX_RESTART_NOW;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4336
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4337
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4338
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4339
static void e1000e_check_82574_phy_workaround(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4340
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4341
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4342
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4343
	/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4344
	 * With 82574 controllers, PHY needs to be checked periodically
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4345
	 * for hung state and reset, if two calls return true
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4346
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4347
	if (e1000_check_phy_82574(hw))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4348
		adapter->phy_hang_count++;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4349
	else
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4350
		adapter->phy_hang_count = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4351
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4352
	if (adapter->phy_hang_count > 1) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4353
		adapter->phy_hang_count = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4354
		schedule_work(&adapter->reset_task);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4355
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4356
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4357
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4358
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4359
 * e1000_watchdog - Timer Call-back
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4360
 * @data: pointer to adapter cast into an unsigned long
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4361
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4362
static void e1000_watchdog(unsigned long data)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4363
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4364
	struct e1000_adapter *adapter = (struct e1000_adapter *) data;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4365
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4366
	/* Do the rest outside of interrupt context */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4367
	schedule_work(&adapter->watchdog_task);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4368
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4369
	/* TODO: make this use queue_delayed_work() */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4370
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4371
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4372
static void e1000_watchdog_task(struct work_struct *work)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4373
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4374
	struct e1000_adapter *adapter = container_of(work,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4375
					struct e1000_adapter, watchdog_task);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4376
	struct net_device *netdev = adapter->netdev;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4377
	struct e1000_mac_info *mac = &adapter->hw.mac;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4378
	struct e1000_phy_info *phy = &adapter->hw.phy;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4379
	struct e1000_ring *tx_ring = adapter->tx_ring;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4380
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4381
	u32 link, tctl;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4382
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4383
	if (test_bit(__E1000_DOWN, &adapter->state))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4384
		return;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4385
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4386
	link = e1000e_has_link(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4387
	if ((adapter->ecdev && (ecdev_get_link(adapter->ecdev)) && link)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4388
			|| (!adapter->ecdev && (netif_carrier_ok(netdev)) && link)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4389
		if (!adapter->ecdev) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4390
			/* Cancel scheduled suspend requests. */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4391
			pm_runtime_resume(netdev->dev.parent);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4392
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4393
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4394
		e1000e_enable_receives(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4395
		goto link_up;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4396
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4397
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4398
	if ((e1000e_enable_tx_pkt_filtering(hw)) &&
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4399
	    (adapter->mng_vlan_id != adapter->hw.mng_cookie.vlan_id))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4400
		e1000_update_mng_vlan(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4401
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4402
	if (link) {
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  4403
		if ((adapter->ecdev && !ecdev_get_link(adapter->ecdev))
2406
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4404
				|| (!adapter->ecdev && !netif_carrier_ok(netdev))) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4405
			bool txb2b = 1;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4406
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4407
			/* Cancel scheduled suspend requests. */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4408
			pm_runtime_resume(netdev->dev.parent);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4409
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4410
			/* update snapshot of PHY registers on LSC */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4411
			e1000_phy_read_status(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4412
			mac->ops.get_link_up_info(&adapter->hw,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4413
						   &adapter->link_speed,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4414
						   &adapter->link_duplex);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4415
			e1000_print_link_info(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4416
			/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4417
			 * On supported PHYs, check for duplex mismatch only
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4418
			 * if link has autonegotiated at 10/100 half
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4419
			 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4420
			if ((hw->phy.type == e1000_phy_igp_3 ||
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4421
			     hw->phy.type == e1000_phy_bm) &&
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4422
			    (hw->mac.autoneg == true) &&
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4423
			    (adapter->link_speed == SPEED_10 ||
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4424
			     adapter->link_speed == SPEED_100) &&
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4425
			    (adapter->link_duplex == HALF_DUPLEX)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4426
				u16 autoneg_exp;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4427
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4428
				e1e_rphy(hw, PHY_AUTONEG_EXP, &autoneg_exp);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4429
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4430
				if (!(autoneg_exp & NWAY_ER_LP_NWAY_CAPS))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4431
					e_info("Autonegotiated half duplex but"
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4432
					       " link partner cannot autoneg. "
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4433
					       " Try forcing full duplex if "
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4434
					       "link gets many collisions.\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4435
			}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4436
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4437
			/* adjust timeout factor according to speed/duplex */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4438
			adapter->tx_timeout_factor = 1;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4439
			switch (adapter->link_speed) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4440
			case SPEED_10:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4441
				txb2b = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4442
				adapter->tx_timeout_factor = 16;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4443
				break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4444
			case SPEED_100:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4445
				txb2b = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4446
				adapter->tx_timeout_factor = 10;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4447
				break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4448
			}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4449
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4450
			/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4451
			 * workaround: re-program speed mode bit after
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4452
			 * link-up event
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4453
			 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4454
			if ((adapter->flags & FLAG_TARC_SPEED_MODE_BIT) &&
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4455
			    !txb2b) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4456
				u32 tarc0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4457
				tarc0 = er32(TARC(0));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4458
				tarc0 &= ~SPEED_MODE_BIT;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4459
				ew32(TARC(0), tarc0);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4460
			}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4461
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4462
			/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4463
			 * disable TSO for pcie and 10/100 speeds, to avoid
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4464
			 * some hardware issues
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4465
			 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4466
			if (!(adapter->flags & FLAG_TSO_FORCE)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4467
				switch (adapter->link_speed) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4468
				case SPEED_10:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4469
				case SPEED_100:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4470
					e_info("10/100 speed: disabling TSO\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4471
					netdev->features &= ~NETIF_F_TSO;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4472
					netdev->features &= ~NETIF_F_TSO6;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4473
					break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4474
				case SPEED_1000:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4475
					netdev->features |= NETIF_F_TSO;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4476
					netdev->features |= NETIF_F_TSO6;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4477
					break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4478
				default:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4479
					/* oops */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4480
					break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4481
				}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4482
			}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4483
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4484
			/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4485
			 * enable transmits in the hardware, need to do this
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4486
			 * after setting TARC(0)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4487
			 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4488
			tctl = er32(TCTL);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4489
			tctl |= E1000_TCTL_EN;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4490
			ew32(TCTL, tctl);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4491
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4492
                        /*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4493
			 * Perform any post-link-up configuration before
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4494
			 * reporting link up.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4495
			 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4496
			if (phy->ops.cfg_on_link_up)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4497
				phy->ops.cfg_on_link_up(hw);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4498
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4499
			if (adapter->ecdev)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4500
				ecdev_set_link(adapter->ecdev, 1);
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  4501
			else
2406
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4502
				netif_carrier_on(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4503
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4504
			if (!adapter->ecdev && !test_bit(__E1000_DOWN, &adapter->state))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4505
				mod_timer(&adapter->phy_info_timer,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4506
					  round_jiffies(jiffies + 2 * HZ));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4507
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4508
	} else {
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  4509
		if ((adapter->ecdev && ecdev_get_link(adapter->ecdev))
2406
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4510
				|| (!adapter->ecdev && netif_carrier_ok(netdev))) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4511
			adapter->link_speed = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4512
			adapter->link_duplex = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4513
			/* Link status message must follow this format */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4514
			printk(KERN_INFO "e1000e: %s NIC Link is Down\n",
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4515
			       adapter->netdev->name);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4516
			if (adapter->ecdev)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4517
				ecdev_set_link(adapter->ecdev, 0);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4518
			else
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4519
				netif_carrier_off(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4520
			if (!adapter->ecdev && !test_bit(__E1000_DOWN, &adapter->state))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4521
				mod_timer(&adapter->phy_info_timer,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4522
					  round_jiffies(jiffies + 2 * HZ));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4523
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4524
			if (adapter->flags & FLAG_RX_NEEDS_RESTART)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4525
				schedule_work(&adapter->reset_task);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4526
			else
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4527
				pm_schedule_suspend(netdev->dev.parent,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4528
							LINK_TIMEOUT);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4529
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4530
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4531
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4532
link_up:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4533
	spin_lock(&adapter->stats64_lock);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4534
	e1000e_update_stats(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4535
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4536
	mac->tx_packet_delta = adapter->stats.tpt - adapter->tpt_old;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4537
	adapter->tpt_old = adapter->stats.tpt;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4538
	mac->collision_delta = adapter->stats.colc - adapter->colc_old;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4539
	adapter->colc_old = adapter->stats.colc;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4540
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4541
	adapter->gorc = adapter->stats.gorc - adapter->gorc_old;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4542
	adapter->gorc_old = adapter->stats.gorc;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4543
	adapter->gotc = adapter->stats.gotc - adapter->gotc_old;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4544
	adapter->gotc_old = adapter->stats.gotc;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4545
	spin_unlock(&adapter->stats64_lock);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4546
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4547
	e1000e_update_adaptive(&adapter->hw);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4548
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  4549
	if (!adapter->ecdev && !netif_carrier_ok(netdev) &&
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  4550
		(e1000_desc_unused(tx_ring) + 1 < tx_ring->count)) {
2406
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4551
		/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4552
		 * We've lost link, so the controller stops DMA,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4553
		 * but we've got queued Tx work that's never going
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4554
		 * to get done, so reset controller to flush Tx.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4555
		 * (Do the reset outside of interrupt context).
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4556
		 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4557
		schedule_work(&adapter->reset_task);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4558
		/* return immediately since reset is imminent */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4559
		return;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4560
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4561
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4562
	/* Simple mode for Interrupt Throttle Rate (ITR) */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4563
	if (adapter->itr_setting == 4) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4564
		/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4565
		 * Symmetric Tx/Rx gets a reduced ITR=2000;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4566
		 * Total asymmetrical Tx or Rx gets ITR=8000;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4567
		 * everyone else is between 2000-8000.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4568
		 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4569
		u32 goc = (adapter->gotc + adapter->gorc) / 10000;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4570
		u32 dif = (adapter->gotc > adapter->gorc ?
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4571
			    adapter->gotc - adapter->gorc :
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4572
			    adapter->gorc - adapter->gotc) / 10000;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4573
		u32 itr = goc > 0 ? (dif * 6000 / goc + 2000) : 8000;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4574
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4575
		ew32(ITR, 1000000000 / (itr * 256));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4576
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4577
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4578
	/* Cause software interrupt to ensure Rx ring is cleaned */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4579
	if (adapter->msix_entries)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4580
		ew32(ICS, adapter->rx_ring->ims_val);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4581
	else
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4582
		ew32(ICS, E1000_ICS_RXDMT0);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4583
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4584
	/* flush pending descriptors to memory before detecting Tx hang */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4585
	e1000e_flush_descriptors(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4586
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4587
	/* Force detection of hung controller every watchdog period */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4588
	adapter->detect_tx_hung = 1;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4589
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4590
	/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4591
	 * With 82571 controllers, LAA may be overwritten due to controller
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4592
	 * reset from the other port. Set the appropriate LAA in RAR[0]
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4593
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4594
	if (e1000e_get_laa_state_82571(hw))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4595
		e1000e_rar_set(hw, adapter->hw.mac.addr, 0);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4596
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4597
	if (adapter->flags2 & FLAG2_CHECK_PHY_HANG)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4598
		e1000e_check_82574_phy_workaround(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4599
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4600
	/* Reset the timer */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4601
	if (!adapter->ecdev && !test_bit(__E1000_DOWN, &adapter->state))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4602
		mod_timer(&adapter->watchdog_timer,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4603
			  round_jiffies(jiffies + 2 * HZ));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4604
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4605
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4606
#define E1000_TX_FLAGS_CSUM		0x00000001
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4607
#define E1000_TX_FLAGS_VLAN		0x00000002
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4608
#define E1000_TX_FLAGS_TSO		0x00000004
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4609
#define E1000_TX_FLAGS_IPV4		0x00000008
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4610
#define E1000_TX_FLAGS_VLAN_MASK	0xffff0000
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4611
#define E1000_TX_FLAGS_VLAN_SHIFT	16
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4612
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4613
static int e1000_tso(struct e1000_adapter *adapter,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4614
		     struct sk_buff *skb)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4615
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4616
	struct e1000_ring *tx_ring = adapter->tx_ring;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4617
	struct e1000_context_desc *context_desc;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4618
	struct e1000_buffer *buffer_info;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4619
	unsigned int i;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4620
	u32 cmd_length = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4621
	u16 ipcse = 0, tucse, mss;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4622
	u8 ipcss, ipcso, tucss, tucso, hdr_len;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4623
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4624
	if (!skb_is_gso(skb))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4625
		return 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4626
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4627
	if (skb_header_cloned(skb)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4628
		int err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4629
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4630
		if (err)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4631
			return err;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4632
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4633
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4634
	hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4635
	mss = skb_shinfo(skb)->gso_size;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4636
	if (skb->protocol == htons(ETH_P_IP)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4637
		struct iphdr *iph = ip_hdr(skb);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4638
		iph->tot_len = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4639
		iph->check = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4640
		tcp_hdr(skb)->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4641
		                                         0, IPPROTO_TCP, 0);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4642
		cmd_length = E1000_TXD_CMD_IP;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4643
		ipcse = skb_transport_offset(skb) - 1;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4644
	} else if (skb_is_gso_v6(skb)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4645
		ipv6_hdr(skb)->payload_len = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4646
		tcp_hdr(skb)->check = ~csum_ipv6_magic(&ipv6_hdr(skb)->saddr,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4647
		                                       &ipv6_hdr(skb)->daddr,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4648
		                                       0, IPPROTO_TCP, 0);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4649
		ipcse = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4650
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4651
	ipcss = skb_network_offset(skb);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4652
	ipcso = (void *)&(ip_hdr(skb)->check) - (void *)skb->data;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4653
	tucss = skb_transport_offset(skb);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4654
	tucso = (void *)&(tcp_hdr(skb)->check) - (void *)skb->data;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4655
	tucse = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4656
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4657
	cmd_length |= (E1000_TXD_CMD_DEXT | E1000_TXD_CMD_TSE |
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4658
	               E1000_TXD_CMD_TCP | (skb->len - (hdr_len)));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4659
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4660
	i = tx_ring->next_to_use;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4661
	context_desc = E1000_CONTEXT_DESC(*tx_ring, i);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4662
	buffer_info = &tx_ring->buffer_info[i];
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4663
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4664
	context_desc->lower_setup.ip_fields.ipcss  = ipcss;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4665
	context_desc->lower_setup.ip_fields.ipcso  = ipcso;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4666
	context_desc->lower_setup.ip_fields.ipcse  = cpu_to_le16(ipcse);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4667
	context_desc->upper_setup.tcp_fields.tucss = tucss;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4668
	context_desc->upper_setup.tcp_fields.tucso = tucso;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4669
	context_desc->upper_setup.tcp_fields.tucse = cpu_to_le16(tucse);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4670
	context_desc->tcp_seg_setup.fields.mss     = cpu_to_le16(mss);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4671
	context_desc->tcp_seg_setup.fields.hdr_len = hdr_len;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4672
	context_desc->cmd_and_length = cpu_to_le32(cmd_length);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4673
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4674
	buffer_info->time_stamp = jiffies;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4675
	buffer_info->next_to_watch = i;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4676
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4677
	i++;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4678
	if (i == tx_ring->count)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4679
		i = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4680
	tx_ring->next_to_use = i;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4681
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4682
	return 1;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4683
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4684
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4685
static bool e1000_tx_csum(struct e1000_adapter *adapter, struct sk_buff *skb)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4686
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4687
	struct e1000_ring *tx_ring = adapter->tx_ring;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4688
	struct e1000_context_desc *context_desc;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4689
	struct e1000_buffer *buffer_info;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4690
	unsigned int i;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4691
	u8 css;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4692
	u32 cmd_len = E1000_TXD_CMD_DEXT;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4693
	__be16 protocol;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4694
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4695
	if (skb->ip_summed != CHECKSUM_PARTIAL)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4696
		return 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4697
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4698
	if (skb->protocol == cpu_to_be16(ETH_P_8021Q))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4699
		protocol = vlan_eth_hdr(skb)->h_vlan_encapsulated_proto;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4700
	else
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4701
		protocol = skb->protocol;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4702
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4703
	switch (protocol) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4704
	case cpu_to_be16(ETH_P_IP):
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4705
		if (ip_hdr(skb)->protocol == IPPROTO_TCP)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4706
			cmd_len |= E1000_TXD_CMD_TCP;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4707
		break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4708
	case cpu_to_be16(ETH_P_IPV6):
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4709
		/* XXX not handling all IPV6 headers */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4710
		if (ipv6_hdr(skb)->nexthdr == IPPROTO_TCP)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4711
			cmd_len |= E1000_TXD_CMD_TCP;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4712
		break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4713
	default:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4714
		if (unlikely(net_ratelimit()))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4715
			e_warn("checksum_partial proto=%x!\n",
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4716
			       be16_to_cpu(protocol));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4717
		break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4718
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4719
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4720
	css = skb_checksum_start_offset(skb);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4721
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4722
	i = tx_ring->next_to_use;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4723
	buffer_info = &tx_ring->buffer_info[i];
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4724
	context_desc = E1000_CONTEXT_DESC(*tx_ring, i);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4725
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4726
	context_desc->lower_setup.ip_config = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4727
	context_desc->upper_setup.tcp_fields.tucss = css;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4728
	context_desc->upper_setup.tcp_fields.tucso =
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4729
				css + skb->csum_offset;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4730
	context_desc->upper_setup.tcp_fields.tucse = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4731
	context_desc->tcp_seg_setup.data = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4732
	context_desc->cmd_and_length = cpu_to_le32(cmd_len);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4733
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4734
	buffer_info->time_stamp = jiffies;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4735
	buffer_info->next_to_watch = i;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4736
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4737
	i++;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4738
	if (i == tx_ring->count)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4739
		i = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4740
	tx_ring->next_to_use = i;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4741
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4742
	return 1;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4743
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4744
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4745
#define E1000_MAX_PER_TXD	8192
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4746
#define E1000_MAX_TXD_PWR	12
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4747
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4748
static int e1000_tx_map(struct e1000_adapter *adapter,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4749
			struct sk_buff *skb, unsigned int first,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4750
			unsigned int max_per_txd, unsigned int nr_frags,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4751
			unsigned int mss)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4752
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4753
	struct e1000_ring *tx_ring = adapter->tx_ring;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4754
	struct pci_dev *pdev = adapter->pdev;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4755
	struct e1000_buffer *buffer_info;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4756
	unsigned int len = skb_headlen(skb);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4757
	unsigned int offset = 0, size, count = 0, i;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4758
	unsigned int f, bytecount, segs;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4759
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4760
	i = tx_ring->next_to_use;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4761
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4762
	while (len) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4763
		buffer_info = &tx_ring->buffer_info[i];
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4764
		size = min(len, max_per_txd);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4765
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4766
		buffer_info->length = size;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4767
		buffer_info->time_stamp = jiffies;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4768
		buffer_info->next_to_watch = i;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4769
		buffer_info->dma = dma_map_single(&pdev->dev,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4770
						  skb->data + offset,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4771
						  size, DMA_TO_DEVICE);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4772
		buffer_info->mapped_as_page = false;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4773
		if (dma_mapping_error(&pdev->dev, buffer_info->dma))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4774
			goto dma_error;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4775
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4776
		len -= size;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4777
		offset += size;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4778
		count++;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4779
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4780
		if (len) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4781
			i++;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4782
			if (i == tx_ring->count)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4783
				i = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4784
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4785
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4786
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4787
	for (f = 0; f < nr_frags; f++) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4788
		const struct skb_frag_struct *frag;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4789
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4790
		frag = &skb_shinfo(skb)->frags[f];
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4791
		len = skb_frag_size(frag);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4792
		offset = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4793
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4794
		while (len) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4795
			i++;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4796
			if (i == tx_ring->count)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4797
				i = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4798
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4799
			buffer_info = &tx_ring->buffer_info[i];
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4800
			size = min(len, max_per_txd);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4801
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4802
			buffer_info->length = size;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4803
			buffer_info->time_stamp = jiffies;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4804
			buffer_info->next_to_watch = i;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4805
			buffer_info->dma = skb_frag_dma_map(&pdev->dev, frag,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4806
						offset, size, DMA_TO_DEVICE);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4807
			buffer_info->mapped_as_page = true;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4808
			if (dma_mapping_error(&pdev->dev, buffer_info->dma))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4809
				goto dma_error;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4810
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4811
			len -= size;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4812
			offset += size;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4813
			count++;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4814
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4815
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4816
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4817
	segs = skb_shinfo(skb)->gso_segs ? : 1;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4818
	/* multiply data chunks by size of headers */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4819
	bytecount = ((segs - 1) * skb_headlen(skb)) + skb->len;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4820
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4821
	tx_ring->buffer_info[i].skb = skb;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4822
	tx_ring->buffer_info[i].segs = segs;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4823
	tx_ring->buffer_info[i].bytecount = bytecount;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4824
	tx_ring->buffer_info[first].next_to_watch = i;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4825
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4826
	return count;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4827
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4828
dma_error:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4829
	dev_err(&pdev->dev, "Tx DMA map failed\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4830
	buffer_info->dma = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4831
	if (count)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4832
		count--;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4833
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4834
	while (count--) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4835
		if (i == 0)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4836
			i += tx_ring->count;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4837
		i--;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4838
		buffer_info = &tx_ring->buffer_info[i];
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4839
		e1000_put_txbuf(adapter, buffer_info);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4840
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4841
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4842
	return 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4843
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4844
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4845
static void e1000_tx_queue(struct e1000_adapter *adapter,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4846
			   int tx_flags, int count)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4847
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4848
	struct e1000_ring *tx_ring = adapter->tx_ring;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4849
	struct e1000_tx_desc *tx_desc = NULL;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4850
	struct e1000_buffer *buffer_info;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4851
	u32 txd_upper = 0, txd_lower = E1000_TXD_CMD_IFCS;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4852
	unsigned int i;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4853
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4854
	if (tx_flags & E1000_TX_FLAGS_TSO) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4855
		txd_lower |= E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D |
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4856
			     E1000_TXD_CMD_TSE;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4857
		txd_upper |= E1000_TXD_POPTS_TXSM << 8;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4858
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4859
		if (tx_flags & E1000_TX_FLAGS_IPV4)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4860
			txd_upper |= E1000_TXD_POPTS_IXSM << 8;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4861
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4862
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4863
	if (tx_flags & E1000_TX_FLAGS_CSUM) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4864
		txd_lower |= E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4865
		txd_upper |= E1000_TXD_POPTS_TXSM << 8;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4866
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4867
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4868
	if (tx_flags & E1000_TX_FLAGS_VLAN) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4869
		txd_lower |= E1000_TXD_CMD_VLE;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4870
		txd_upper |= (tx_flags & E1000_TX_FLAGS_VLAN_MASK);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4871
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4872
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4873
	i = tx_ring->next_to_use;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4874
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4875
	do {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4876
		buffer_info = &tx_ring->buffer_info[i];
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4877
		tx_desc = E1000_TX_DESC(*tx_ring, i);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4878
		tx_desc->buffer_addr = cpu_to_le64(buffer_info->dma);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4879
		tx_desc->lower.data =
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4880
			cpu_to_le32(txd_lower | buffer_info->length);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4881
		tx_desc->upper.data = cpu_to_le32(txd_upper);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4882
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4883
		i++;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4884
		if (i == tx_ring->count)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4885
			i = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4886
	} while (--count > 0);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4887
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4888
	tx_desc->lower.data |= cpu_to_le32(adapter->txd_cmd);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4889
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4890
	/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4891
	 * Force memory writes to complete before letting h/w
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4892
	 * know there are new descriptors to fetch.  (Only
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4893
	 * applicable for weak-ordered memory model archs,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4894
	 * such as IA-64).
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4895
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4896
	wmb();
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4897
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4898
	tx_ring->next_to_use = i;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4899
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4900
	if (adapter->flags2 & FLAG2_PCIM2PCI_ARBITER_WA)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4901
		e1000e_update_tdt_wa(adapter, i);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4902
	else
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4903
		writel(i, adapter->hw.hw_addr + tx_ring->tail);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4904
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4905
	/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4906
	 * we need this if more than one processor can write to our tail
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4907
	 * at a time, it synchronizes IO on IA64/Altix systems
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4908
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4909
	mmiowb();
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4910
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4911
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4912
#define MINIMUM_DHCP_PACKET_SIZE 282
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4913
static int e1000_transfer_dhcp_info(struct e1000_adapter *adapter,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4914
				    struct sk_buff *skb)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4915
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4916
	struct e1000_hw *hw =  &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4917
	u16 length, offset;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4918
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4919
	if (vlan_tx_tag_present(skb)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4920
		if (!((vlan_tx_tag_get(skb) == adapter->hw.mng_cookie.vlan_id) &&
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4921
		    (adapter->hw.mng_cookie.status &
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4922
			E1000_MNG_DHCP_COOKIE_STATUS_VLAN)))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4923
			return 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4924
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4925
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4926
	if (skb->len <= MINIMUM_DHCP_PACKET_SIZE)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4927
		return 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4928
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4929
	if (((struct ethhdr *) skb->data)->h_proto != htons(ETH_P_IP))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4930
		return 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4931
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4932
	{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4933
		const struct iphdr *ip = (struct iphdr *)((u8 *)skb->data+14);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4934
		struct udphdr *udp;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4935
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4936
		if (ip->protocol != IPPROTO_UDP)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4937
			return 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4938
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4939
		udp = (struct udphdr *)((u8 *)ip + (ip->ihl << 2));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4940
		if (ntohs(udp->dest) != 67)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4941
			return 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4942
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4943
		offset = (u8 *)udp + 8 - skb->data;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4944
		length = skb->len - offset;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4945
		return e1000e_mng_write_dhcp_info(hw, (u8 *)udp + 8, length);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4946
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4947
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4948
	return 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4949
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4950
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4951
static int __e1000_maybe_stop_tx(struct net_device *netdev, int size)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4952
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4953
	struct e1000_adapter *adapter = netdev_priv(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4954
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  4955
	if (adapter->ecdev) {
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  4956
		return -EBUSY;
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  4957
	}
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  4958
2406
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4959
	netif_stop_queue(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4960
	/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4961
	 * Herbert's original patch had:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4962
	 *  smp_mb__after_netif_stop_queue();
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4963
	 * but since that doesn't exist yet, just open code it.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4964
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4965
	smp_mb();
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4966
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4967
	/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4968
	 * We need to check again in a case another CPU has just
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4969
	 * made room available.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4970
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4971
	if (e1000_desc_unused(adapter->tx_ring) < size)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4972
		return -EBUSY;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4973
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4974
	/* A reprieve! */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4975
	netif_start_queue(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4976
	++adapter->restart_queue;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4977
	return 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4978
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4979
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4980
static int e1000_maybe_stop_tx(struct net_device *netdev, int size)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4981
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4982
	struct e1000_adapter *adapter = netdev_priv(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4983
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4984
	if (e1000_desc_unused(adapter->tx_ring) >= size)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4985
		return 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4986
	return __e1000_maybe_stop_tx(netdev, size);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4987
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4988
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4989
#define TXD_USE_COUNT(S, X) (((S) >> (X)) + 1 )
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4990
static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4991
				    struct net_device *netdev)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4992
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4993
	struct e1000_adapter *adapter = netdev_priv(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4994
	struct e1000_ring *tx_ring = adapter->tx_ring;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4995
	unsigned int first;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4996
	unsigned int max_per_txd = E1000_MAX_PER_TXD;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4997
	unsigned int max_txd_pwr = E1000_MAX_TXD_PWR;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4998
	unsigned int tx_flags = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4999
	unsigned int len = skb_headlen(skb);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5000
	unsigned int nr_frags;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5001
	unsigned int mss;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5002
	int count = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5003
	int tso;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5004
	unsigned int f;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5005
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5006
	if (test_bit(__E1000_DOWN, &adapter->state)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5007
		if (!adapter->ecdev)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5008
			dev_kfree_skb_any(skb);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5009
		return NETDEV_TX_OK;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5010
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5011
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5012
	if (skb->len <= 0) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5013
		if (!adapter->ecdev)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5014
			dev_kfree_skb_any(skb);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5015
		return NETDEV_TX_OK;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5016
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5017
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5018
	mss = skb_shinfo(skb)->gso_size;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5019
	/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5020
	 * The controller does a simple calculation to
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5021
	 * make sure there is enough room in the FIFO before
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5022
	 * initiating the DMA for each buffer.  The calc is:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5023
	 * 4 = ceil(buffer len/mss).  To make sure we don't
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5024
	 * overrun the FIFO, adjust the max buffer len if mss
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5025
	 * drops.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5026
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5027
	if (mss) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5028
		u8 hdr_len;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5029
		max_per_txd = min(mss << 2, max_per_txd);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5030
		max_txd_pwr = fls(max_per_txd) - 1;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5031
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5032
		/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5033
		 * TSO Workaround for 82571/2/3 Controllers -- if skb->data
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5034
		 * points to just header, pull a few bytes of payload from
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5035
		 * frags into skb->data
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5036
		 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5037
		hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5038
		/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5039
		 * we do this workaround for ES2LAN, but it is un-necessary,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5040
		 * avoiding it could save a lot of cycles
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5041
		 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5042
		if (skb->data_len && (hdr_len == len)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5043
			unsigned int pull_size;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5044
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5045
			pull_size = min((unsigned int)4, skb->data_len);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5046
			if (!__pskb_pull_tail(skb, pull_size)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5047
				e_err("__pskb_pull_tail failed.\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5048
				if (!adapter->ecdev)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5049
					dev_kfree_skb_any(skb);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5050
				return NETDEV_TX_OK;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5051
			}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5052
			len = skb_headlen(skb);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5053
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5054
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5055
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5056
	/* reserve a descriptor for the offload context */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5057
	if ((mss) || (skb->ip_summed == CHECKSUM_PARTIAL))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5058
		count++;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5059
	count++;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5060
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5061
	count += TXD_USE_COUNT(len, max_txd_pwr);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5062
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5063
	nr_frags = skb_shinfo(skb)->nr_frags;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5064
	for (f = 0; f < nr_frags; f++)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5065
		count += TXD_USE_COUNT(skb_frag_size(&skb_shinfo(skb)->frags[f]),
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5066
				       max_txd_pwr);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5067
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5068
	if (adapter->hw.mac.tx_pkt_filtering)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5069
		e1000_transfer_dhcp_info(adapter, skb);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5070
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5071
	/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5072
	 * need: count + 2 desc gap to keep tail from touching
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5073
	 * head, otherwise try next time
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5074
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5075
	if (!adapter->ecdev && e1000_maybe_stop_tx(netdev, count + 2))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5076
		return NETDEV_TX_BUSY;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5077
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5078
	if (vlan_tx_tag_present(skb)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5079
		tx_flags |= E1000_TX_FLAGS_VLAN;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5080
		tx_flags |= (vlan_tx_tag_get(skb) << E1000_TX_FLAGS_VLAN_SHIFT);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5081
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5082
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5083
	first = tx_ring->next_to_use;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5084
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5085
	tso = e1000_tso(adapter, skb);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5086
	if (tso < 0) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5087
		if (!adapter->ecdev)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5088
			dev_kfree_skb_any(skb);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5089
		return NETDEV_TX_OK;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5090
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5091
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5092
	if (tso)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5093
		tx_flags |= E1000_TX_FLAGS_TSO;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5094
	else if (e1000_tx_csum(adapter, skb))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5095
		tx_flags |= E1000_TX_FLAGS_CSUM;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5096
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5097
	/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5098
	 * Old method was to assume IPv4 packet by default if TSO was enabled.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5099
	 * 82571 hardware supports TSO capabilities for IPv6 as well...
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5100
	 * no longer assume, we must.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5101
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5102
	if (skb->protocol == htons(ETH_P_IP))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5103
		tx_flags |= E1000_TX_FLAGS_IPV4;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5104
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5105
	/* if count is 0 then mapping error has occurred */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5106
	count = e1000_tx_map(adapter, skb, first, max_per_txd, nr_frags, mss);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5107
	if (count) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5108
		e1000_tx_queue(adapter, tx_flags, count);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5109
		/* Make sure there is space in the ring for the next send. */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5110
		if (!adapter->ecdev)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5111
			e1000_maybe_stop_tx(netdev, MAX_SKB_FRAGS + 2);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5112
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5113
	} else {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5114
		if (!adapter->ecdev)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5115
			dev_kfree_skb_any(skb);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5116
		tx_ring->buffer_info[first].time_stamp = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5117
		tx_ring->next_to_use = first;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5118
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5119
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5120
	return NETDEV_TX_OK;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5121
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5122
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5123
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5124
 * e1000_tx_timeout - Respond to a Tx Hang
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5125
 * @netdev: network interface device structure
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5126
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5127
static void e1000_tx_timeout(struct net_device *netdev)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5128
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5129
	struct e1000_adapter *adapter = netdev_priv(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5130
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5131
	/* Do the reset outside of interrupt context */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5132
	adapter->tx_timeout_count++;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5133
	schedule_work(&adapter->reset_task);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5134
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5135
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5136
static void e1000_reset_task(struct work_struct *work)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5137
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5138
	struct e1000_adapter *adapter;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5139
	adapter = container_of(work, struct e1000_adapter, reset_task);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5140
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5141
	/* don't run the task if already down */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5142
	if (test_bit(__E1000_DOWN, &adapter->state))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5143
		return;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5144
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5145
	if (!((adapter->flags & FLAG_RX_NEEDS_RESTART) &&
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5146
	      (adapter->flags & FLAG_RX_RESTART_NOW))) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5147
		e1000e_dump(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5148
		e_err("Reset adapter\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5149
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5150
	e1000e_reinit_locked(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5151
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5152
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5153
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5154
 * e1000_get_stats64 - Get System Network Statistics
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5155
 * @netdev: network interface device structure
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5156
 * @stats: rtnl_link_stats64 pointer
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5157
 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5158
 * Returns the address of the device statistics structure.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5159
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5160
struct rtnl_link_stats64 *e1000e_get_stats64(struct net_device *netdev,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5161
                                             struct rtnl_link_stats64 *stats)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5162
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5163
	struct e1000_adapter *adapter = netdev_priv(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5164
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5165
	memset(stats, 0, sizeof(struct rtnl_link_stats64));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5166
	spin_lock(&adapter->stats64_lock);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5167
	e1000e_update_stats(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5168
	/* Fill out the OS statistics structure */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5169
	stats->rx_bytes = adapter->stats.gorc;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5170
	stats->rx_packets = adapter->stats.gprc;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5171
	stats->tx_bytes = adapter->stats.gotc;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5172
	stats->tx_packets = adapter->stats.gptc;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5173
	stats->multicast = adapter->stats.mprc;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5174
	stats->collisions = adapter->stats.colc;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5175
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5176
	/* Rx Errors */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5177
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5178
	/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5179
	 * RLEC on some newer hardware can be incorrect so build
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5180
	 * our own version based on RUC and ROC
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5181
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5182
	stats->rx_errors = adapter->stats.rxerrc +
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5183
		adapter->stats.crcerrs + adapter->stats.algnerrc +
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5184
		adapter->stats.ruc + adapter->stats.roc +
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5185
		adapter->stats.cexterr;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5186
	stats->rx_length_errors = adapter->stats.ruc +
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5187
					      adapter->stats.roc;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5188
	stats->rx_crc_errors = adapter->stats.crcerrs;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5189
	stats->rx_frame_errors = adapter->stats.algnerrc;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5190
	stats->rx_missed_errors = adapter->stats.mpc;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5191
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5192
	/* Tx Errors */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5193
	stats->tx_errors = adapter->stats.ecol +
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5194
				       adapter->stats.latecol;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5195
	stats->tx_aborted_errors = adapter->stats.ecol;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5196
	stats->tx_window_errors = adapter->stats.latecol;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5197
	stats->tx_carrier_errors = adapter->stats.tncrs;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5198
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5199
	/* Tx Dropped needs to be maintained elsewhere */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5200
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5201
	spin_unlock(&adapter->stats64_lock);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5202
	return stats;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5203
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5204
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5205
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5206
 * e1000_change_mtu - Change the Maximum Transfer Unit
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5207
 * @netdev: network interface device structure
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5208
 * @new_mtu: new value for maximum frame size
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5209
 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5210
 * Returns 0 on success, negative on failure
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5211
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5212
static int e1000_change_mtu(struct net_device *netdev, int new_mtu)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5213
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5214
	struct e1000_adapter *adapter = netdev_priv(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5215
	int max_frame = new_mtu + ETH_HLEN + ETH_FCS_LEN;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5216
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5217
	if (adapter->ecdev)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5218
		return -EBUSY;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5219
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5220
	/* Jumbo frame support */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5221
	if ((max_frame > ETH_FRAME_LEN + ETH_FCS_LEN) &&
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5222
	    !(adapter->flags & FLAG_HAS_JUMBO_FRAMES)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5223
		e_err("Jumbo Frames not supported.\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5224
		return -EINVAL;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5225
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5226
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5227
	/* Supported frame sizes */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5228
	if ((new_mtu < ETH_ZLEN + ETH_FCS_LEN + VLAN_HLEN) ||
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5229
	    (max_frame > adapter->max_hw_frame_size)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5230
		e_err("Unsupported MTU setting\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5231
		return -EINVAL;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5232
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5233
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5234
	/* Jumbo frame workaround on 82579 requires CRC be stripped */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5235
	if ((adapter->hw.mac.type == e1000_pch2lan) &&
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5236
	    !(adapter->flags2 & FLAG2_CRC_STRIPPING) &&
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5237
	    (new_mtu > ETH_DATA_LEN)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5238
		e_err("Jumbo Frames not supported on 82579 when CRC "
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5239
		      "stripping is disabled.\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5240
		return -EINVAL;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5241
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5242
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5243
	/* 82573 Errata 17 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5244
	if (((adapter->hw.mac.type == e1000_82573) ||
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5245
	     (adapter->hw.mac.type == e1000_82574)) &&
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5246
	    (max_frame > ETH_FRAME_LEN + ETH_FCS_LEN)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5247
		adapter->flags2 |= FLAG2_DISABLE_ASPM_L1;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5248
		e1000e_disable_aspm(adapter->pdev, PCIE_LINK_STATE_L1);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5249
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5250
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5251
	while (test_and_set_bit(__E1000_RESETTING, &adapter->state))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5252
		usleep_range(1000, 2000);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5253
	/* e1000e_down -> e1000e_reset dependent on max_frame_size & mtu */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5254
	adapter->max_frame_size = max_frame;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5255
	e_info("changing MTU from %d to %d\n", netdev->mtu, new_mtu);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5256
	netdev->mtu = new_mtu;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5257
	if (netif_running(netdev))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5258
		e1000e_down(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5259
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5260
	/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5261
	 * NOTE: netdev_alloc_skb reserves 16 bytes, and typically NET_IP_ALIGN
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5262
	 * means we reserve 2 more, this pushes us to allocate from the next
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5263
	 * larger slab size.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5264
	 * i.e. RXBUFFER_2048 --> size-4096 slab
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5265
	 * However with the new *_jumbo_rx* routines, jumbo receives will use
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5266
	 * fragmented skbs
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5267
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5268
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5269
	if (max_frame <= 2048)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5270
		adapter->rx_buffer_len = 2048;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5271
	else
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5272
		adapter->rx_buffer_len = 4096;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5273
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5274
	/* adjust allocation if LPE protects us, and we aren't using SBP */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5275
	if ((max_frame == ETH_FRAME_LEN + ETH_FCS_LEN) ||
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5276
	     (max_frame == ETH_FRAME_LEN + VLAN_HLEN + ETH_FCS_LEN))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5277
		adapter->rx_buffer_len = ETH_FRAME_LEN + VLAN_HLEN
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5278
					 + ETH_FCS_LEN;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5279
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5280
	if (netif_running(netdev))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5281
		e1000e_up(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5282
	else
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5283
		e1000e_reset(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5284
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5285
	clear_bit(__E1000_RESETTING, &adapter->state);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5286
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5287
	return 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5288
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5289
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5290
static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5291
			   int cmd)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5292
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5293
	struct e1000_adapter *adapter = netdev_priv(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5294
	struct mii_ioctl_data *data = if_mii(ifr);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5295
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5296
	if (adapter->hw.phy.media_type != e1000_media_type_copper)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5297
		return -EOPNOTSUPP;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5298
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5299
	switch (cmd) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5300
	case SIOCGMIIPHY:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5301
		data->phy_id = adapter->hw.phy.addr;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5302
		break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5303
	case SIOCGMIIREG:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5304
		e1000_phy_read_status(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5305
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5306
		switch (data->reg_num & 0x1F) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5307
		case MII_BMCR:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5308
			data->val_out = adapter->phy_regs.bmcr;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5309
			break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5310
		case MII_BMSR:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5311
			data->val_out = adapter->phy_regs.bmsr;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5312
			break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5313
		case MII_PHYSID1:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5314
			data->val_out = (adapter->hw.phy.id >> 16);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5315
			break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5316
		case MII_PHYSID2:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5317
			data->val_out = (adapter->hw.phy.id & 0xFFFF);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5318
			break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5319
		case MII_ADVERTISE:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5320
			data->val_out = adapter->phy_regs.advertise;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5321
			break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5322
		case MII_LPA:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5323
			data->val_out = adapter->phy_regs.lpa;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5324
			break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5325
		case MII_EXPANSION:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5326
			data->val_out = adapter->phy_regs.expansion;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5327
			break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5328
		case MII_CTRL1000:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5329
			data->val_out = adapter->phy_regs.ctrl1000;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5330
			break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5331
		case MII_STAT1000:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5332
			data->val_out = adapter->phy_regs.stat1000;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5333
			break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5334
		case MII_ESTATUS:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5335
			data->val_out = adapter->phy_regs.estatus;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5336
			break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5337
		default:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5338
			return -EIO;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5339
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5340
		break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5341
	case SIOCSMIIREG:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5342
	default:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5343
		return -EOPNOTSUPP;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5344
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5345
	return 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5346
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5347
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5348
static int e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5349
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5350
	switch (cmd) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5351
	case SIOCGMIIPHY:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5352
	case SIOCGMIIREG:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5353
	case SIOCSMIIREG:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5354
		return e1000_mii_ioctl(netdev, ifr, cmd);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5355
	default:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5356
		return -EOPNOTSUPP;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5357
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5358
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5359
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5360
static int e1000_init_phy_wakeup(struct e1000_adapter *adapter, u32 wufc)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5361
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5362
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5363
	u32 i, mac_reg;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5364
	u16 phy_reg, wuc_enable;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5365
	int retval = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5366
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5367
	/* copy MAC RARs to PHY RARs */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5368
	e1000_copy_rx_addrs_to_phy_ich8lan(hw);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5369
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5370
	retval = hw->phy.ops.acquire(hw);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5371
	if (retval) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5372
		e_err("Could not acquire PHY\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5373
		return retval;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5374
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5375
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5376
	/* Enable access to wakeup registers on and set page to BM_WUC_PAGE */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5377
	retval = e1000_enable_phy_wakeup_reg_access_bm(hw, &wuc_enable);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5378
	if (retval)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5379
		goto out;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5380
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5381
	/* copy MAC MTA to PHY MTA - only needed for pchlan */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5382
	for (i = 0; i < adapter->hw.mac.mta_reg_count; i++) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5383
		mac_reg = E1000_READ_REG_ARRAY(hw, E1000_MTA, i);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5384
		hw->phy.ops.write_reg_page(hw, BM_MTA(i),
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5385
					   (u16)(mac_reg & 0xFFFF));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5386
		hw->phy.ops.write_reg_page(hw, BM_MTA(i) + 1,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5387
					   (u16)((mac_reg >> 16) & 0xFFFF));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5388
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5389
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5390
	/* configure PHY Rx Control register */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5391
	hw->phy.ops.read_reg_page(&adapter->hw, BM_RCTL, &phy_reg);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5392
	mac_reg = er32(RCTL);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5393
	if (mac_reg & E1000_RCTL_UPE)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5394
		phy_reg |= BM_RCTL_UPE;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5395
	if (mac_reg & E1000_RCTL_MPE)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5396
		phy_reg |= BM_RCTL_MPE;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5397
	phy_reg &= ~(BM_RCTL_MO_MASK);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5398
	if (mac_reg & E1000_RCTL_MO_3)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5399
		phy_reg |= (((mac_reg & E1000_RCTL_MO_3) >> E1000_RCTL_MO_SHIFT)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5400
				<< BM_RCTL_MO_SHIFT);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5401
	if (mac_reg & E1000_RCTL_BAM)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5402
		phy_reg |= BM_RCTL_BAM;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5403
	if (mac_reg & E1000_RCTL_PMCF)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5404
		phy_reg |= BM_RCTL_PMCF;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5405
	mac_reg = er32(CTRL);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5406
	if (mac_reg & E1000_CTRL_RFCE)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5407
		phy_reg |= BM_RCTL_RFCE;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5408
	hw->phy.ops.write_reg_page(&adapter->hw, BM_RCTL, phy_reg);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5409
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5410
	/* enable PHY wakeup in MAC register */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5411
	ew32(WUFC, wufc);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5412
	ew32(WUC, E1000_WUC_PHY_WAKE | E1000_WUC_PME_EN);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5413
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5414
	/* configure and enable PHY wakeup in PHY registers */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5415
	hw->phy.ops.write_reg_page(&adapter->hw, BM_WUFC, wufc);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5416
	hw->phy.ops.write_reg_page(&adapter->hw, BM_WUC, E1000_WUC_PME_EN);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5417
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5418
	/* activate PHY wakeup */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5419
	wuc_enable |= BM_WUC_ENABLE_BIT | BM_WUC_HOST_WU_BIT;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5420
	retval = e1000_disable_phy_wakeup_reg_access_bm(hw, &wuc_enable);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5421
	if (retval)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5422
		e_err("Could not set PHY Host Wakeup bit\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5423
out:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5424
	hw->phy.ops.release(hw);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5425
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5426
	return retval;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5427
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5428
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5429
static int __e1000_shutdown(struct pci_dev *pdev, bool *enable_wake,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5430
			    bool runtime)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5431
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5432
	struct net_device *netdev = pci_get_drvdata(pdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5433
	struct e1000_adapter *adapter = netdev_priv(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5434
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5435
	u32 ctrl, ctrl_ext, rctl, status;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5436
	/* Runtime suspend should only enable wakeup for link changes */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5437
	u32 wufc = runtime ? E1000_WUFC_LNKC : adapter->wol;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5438
	int retval = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5439
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5440
	netif_device_detach(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5441
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5442
	if (netif_running(netdev)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5443
		WARN_ON(test_bit(__E1000_RESETTING, &adapter->state));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5444
		e1000e_down(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5445
		e1000_free_irq(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5446
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5447
	e1000e_reset_interrupt_capability(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5448
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5449
	retval = pci_save_state(pdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5450
	if (retval)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5451
		return retval;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5452
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5453
	status = er32(STATUS);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5454
	if (status & E1000_STATUS_LU)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5455
		wufc &= ~E1000_WUFC_LNKC;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5456
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5457
	if (wufc) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5458
		e1000_setup_rctl(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5459
		e1000_set_multi(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5460
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5461
		/* turn on all-multi mode if wake on multicast is enabled */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5462
		if (wufc & E1000_WUFC_MC) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5463
			rctl = er32(RCTL);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5464
			rctl |= E1000_RCTL_MPE;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5465
			ew32(RCTL, rctl);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5466
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5467
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5468
		ctrl = er32(CTRL);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5469
		/* advertise wake from D3Cold */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5470
		#define E1000_CTRL_ADVD3WUC 0x00100000
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5471
		/* phy power management enable */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5472
		#define E1000_CTRL_EN_PHY_PWR_MGMT 0x00200000
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5473
		ctrl |= E1000_CTRL_ADVD3WUC;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5474
		if (!(adapter->flags2 & FLAG2_HAS_PHY_WAKEUP))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5475
			ctrl |= E1000_CTRL_EN_PHY_PWR_MGMT;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5476
		ew32(CTRL, ctrl);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5477
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5478
		if (adapter->hw.phy.media_type == e1000_media_type_fiber ||
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5479
		    adapter->hw.phy.media_type ==
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5480
		    e1000_media_type_internal_serdes) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5481
			/* keep the laser running in D3 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5482
			ctrl_ext = er32(CTRL_EXT);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5483
			ctrl_ext |= E1000_CTRL_EXT_SDP3_DATA;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5484
			ew32(CTRL_EXT, ctrl_ext);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5485
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5486
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5487
		if (adapter->flags & FLAG_IS_ICH)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5488
			e1000_suspend_workarounds_ich8lan(&adapter->hw);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5489
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5490
		/* Allow time for pending master requests to run */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5491
		e1000e_disable_pcie_master(&adapter->hw);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5492
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5493
		if (adapter->flags2 & FLAG2_HAS_PHY_WAKEUP) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5494
			/* enable wakeup by the PHY */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5495
			retval = e1000_init_phy_wakeup(adapter, wufc);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5496
			if (retval)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5497
				return retval;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5498
		} else {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5499
			/* enable wakeup by the MAC */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5500
			ew32(WUFC, wufc);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5501
			ew32(WUC, E1000_WUC_PME_EN);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5502
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5503
	} else {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5504
		ew32(WUC, 0);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5505
		ew32(WUFC, 0);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5506
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5507
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5508
	*enable_wake = !!wufc;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5509
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5510
	/* make sure adapter isn't asleep if manageability is enabled */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5511
	if ((adapter->flags & FLAG_MNG_PT_ENABLED) ||
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5512
	    (hw->mac.ops.check_mng_mode(hw)))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5513
		*enable_wake = true;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5514
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5515
	if (adapter->hw.phy.type == e1000_phy_igp_3)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5516
		e1000e_igp3_phy_powerdown_workaround_ich8lan(&adapter->hw);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5517
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5518
	/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5519
	 * Release control of h/w to f/w.  If f/w is AMT enabled, this
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5520
	 * would have already happened in close and is redundant.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5521
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5522
	e1000e_release_hw_control(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5523
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5524
	pci_disable_device(pdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5525
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5526
	return 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5527
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5528
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5529
static void e1000_power_off(struct pci_dev *pdev, bool sleep, bool wake)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5530
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5531
	if (sleep && wake) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5532
		pci_prepare_to_sleep(pdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5533
		return;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5534
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5535
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5536
	pci_wake_from_d3(pdev, wake);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5537
	pci_set_power_state(pdev, PCI_D3hot);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5538
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5539
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5540
static void e1000_complete_shutdown(struct pci_dev *pdev, bool sleep,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5541
                                    bool wake)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5542
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5543
	struct net_device *netdev = pci_get_drvdata(pdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5544
	struct e1000_adapter *adapter = netdev_priv(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5545
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5546
	/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5547
	 * The pci-e switch on some quad port adapters will report a
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5548
	 * correctable error when the MAC transitions from D0 to D3.  To
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5549
	 * prevent this we need to mask off the correctable errors on the
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5550
	 * downstream port of the pci-e switch.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5551
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5552
	if (adapter->flags & FLAG_IS_QUAD_PORT) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5553
		struct pci_dev *us_dev = pdev->bus->self;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5554
		int pos = pci_pcie_cap(us_dev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5555
		u16 devctl;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5556
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5557
		pci_read_config_word(us_dev, pos + PCI_EXP_DEVCTL, &devctl);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5558
		pci_write_config_word(us_dev, pos + PCI_EXP_DEVCTL,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5559
		                      (devctl & ~PCI_EXP_DEVCTL_CERE));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5560
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5561
		e1000_power_off(pdev, sleep, wake);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5562
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5563
		pci_write_config_word(us_dev, pos + PCI_EXP_DEVCTL, devctl);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5564
	} else {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5565
		e1000_power_off(pdev, sleep, wake);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5566
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5567
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5568
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5569
#ifdef CONFIG_PCIEASPM
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5570
static void __e1000e_disable_aspm(struct pci_dev *pdev, u16 state)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5571
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5572
	pci_disable_link_state_locked(pdev, state);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5573
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5574
#else
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5575
static void __e1000e_disable_aspm(struct pci_dev *pdev, u16 state)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5576
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5577
	int pos;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5578
	u16 reg16;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5579
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5580
	/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5581
	 * Both device and parent should have the same ASPM setting.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5582
	 * Disable ASPM in downstream component first and then upstream.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5583
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5584
	pos = pci_pcie_cap(pdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5585
	pci_read_config_word(pdev, pos + PCI_EXP_LNKCTL, &reg16);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5586
	reg16 &= ~state;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5587
	pci_write_config_word(pdev, pos + PCI_EXP_LNKCTL, reg16);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5588
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5589
	if (!pdev->bus->self)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5590
		return;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5591
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5592
	pos = pci_pcie_cap(pdev->bus->self);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5593
	pci_read_config_word(pdev->bus->self, pos + PCI_EXP_LNKCTL, &reg16);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5594
	reg16 &= ~state;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5595
	pci_write_config_word(pdev->bus->self, pos + PCI_EXP_LNKCTL, reg16);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5596
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5597
#endif
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5598
static void e1000e_disable_aspm(struct pci_dev *pdev, u16 state)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5599
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5600
	dev_info(&pdev->dev, "Disabling ASPM %s %s\n",
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5601
		 (state & PCIE_LINK_STATE_L0S) ? "L0s" : "",
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5602
		 (state & PCIE_LINK_STATE_L1) ? "L1" : "");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5603
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5604
	__e1000e_disable_aspm(pdev, state);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5605
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5606
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5607
#ifdef CONFIG_PM
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5608
static bool e1000e_pm_ready(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5609
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5610
	return !!adapter->tx_ring->buffer_info;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5611
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5612
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5613
static int __e1000_resume(struct pci_dev *pdev)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5614
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5615
	struct net_device *netdev = pci_get_drvdata(pdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5616
	struct e1000_adapter *adapter = netdev_priv(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5617
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5618
	u16 aspm_disable_flag = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5619
	u32 err;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5620
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5621
	if (adapter->ecdev)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5622
		return -EBUSY;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5623
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5624
	if (adapter->flags2 & FLAG2_DISABLE_ASPM_L0S)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5625
		aspm_disable_flag = PCIE_LINK_STATE_L0S;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5626
	if (adapter->flags2 & FLAG2_DISABLE_ASPM_L1)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5627
		aspm_disable_flag |= PCIE_LINK_STATE_L1;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5628
	if (aspm_disable_flag)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5629
		e1000e_disable_aspm(pdev, aspm_disable_flag);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5630
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5631
	pci_set_power_state(pdev, PCI_D0);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5632
	pci_restore_state(pdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5633
	pci_save_state(pdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5634
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5635
	e1000e_set_interrupt_capability(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5636
	if (netif_running(netdev)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5637
		err = e1000_request_irq(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5638
		if (err)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5639
			return err;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5640
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5641
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5642
	if (hw->mac.type == e1000_pch2lan)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5643
		e1000_resume_workarounds_pchlan(&adapter->hw);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5644
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5645
	e1000e_power_up_phy(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5646
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5647
	/* report the system wakeup cause from S3/S4 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5648
	if (adapter->flags2 & FLAG2_HAS_PHY_WAKEUP) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5649
		u16 phy_data;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5650
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5651
		e1e_rphy(&adapter->hw, BM_WUS, &phy_data);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5652
		if (phy_data) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5653
			e_info("PHY Wakeup cause - %s\n",
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5654
				phy_data & E1000_WUS_EX ? "Unicast Packet" :
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5655
				phy_data & E1000_WUS_MC ? "Multicast Packet" :
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5656
				phy_data & E1000_WUS_BC ? "Broadcast Packet" :
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5657
				phy_data & E1000_WUS_MAG ? "Magic Packet" :
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5658
				phy_data & E1000_WUS_LNKC ? "Link Status "
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5659
				" Change" : "other");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5660
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5661
		e1e_wphy(&adapter->hw, BM_WUS, ~0);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5662
	} else {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5663
		u32 wus = er32(WUS);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5664
		if (wus) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5665
			e_info("MAC Wakeup cause - %s\n",
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5666
				wus & E1000_WUS_EX ? "Unicast Packet" :
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5667
				wus & E1000_WUS_MC ? "Multicast Packet" :
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5668
				wus & E1000_WUS_BC ? "Broadcast Packet" :
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5669
				wus & E1000_WUS_MAG ? "Magic Packet" :
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5670
				wus & E1000_WUS_LNKC ? "Link Status Change" :
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5671
				"other");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5672
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5673
		ew32(WUS, ~0);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5674
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5675
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5676
	e1000e_reset(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5677
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5678
	e1000_init_manageability_pt(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5679
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5680
	if (netif_running(netdev))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5681
		e1000e_up(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5682
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5683
	netif_device_attach(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5684
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5685
	/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5686
	 * If the controller has AMT, do not set DRV_LOAD until the interface
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5687
	 * is up.  For all other cases, let the f/w know that the h/w is now
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5688
	 * under the control of the driver.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5689
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5690
	if (!(adapter->flags & FLAG_HAS_AMT))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5691
		e1000e_get_hw_control(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5692
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5693
	return 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5694
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5695
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5696
#ifdef CONFIG_PM_SLEEP
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5697
static int e1000_suspend(struct device *dev)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5698
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5699
	struct pci_dev *pdev = to_pci_dev(dev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5700
	int retval;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5701
	bool wake;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5702
	struct net_device *netdev = pci_get_drvdata(pdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5703
	struct e1000_adapter *adapter = netdev_priv(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5704
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5705
	if (adapter->ecdev)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5706
		return -EBUSY;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5707
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5708
	retval = __e1000_shutdown(pdev, &wake, false);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5709
	if (!retval)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5710
		e1000_complete_shutdown(pdev, true, wake);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5711
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5712
	return retval;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5713
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5714
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5715
static int e1000_resume(struct device *dev)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5716
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5717
	struct pci_dev *pdev = to_pci_dev(dev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5718
	struct net_device *netdev = pci_get_drvdata(pdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5719
	struct e1000_adapter *adapter = netdev_priv(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5720
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5721
	if (e1000e_pm_ready(adapter))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5722
		adapter->idle_check = true;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5723
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5724
	return __e1000_resume(pdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5725
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5726
#endif /* CONFIG_PM_SLEEP */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5727
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5728
#ifdef CONFIG_PM_RUNTIME
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5729
static int e1000_runtime_suspend(struct device *dev)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5730
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5731
	struct pci_dev *pdev = to_pci_dev(dev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5732
	struct net_device *netdev = pci_get_drvdata(pdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5733
	struct e1000_adapter *adapter = netdev_priv(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5734
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5735
	if (e1000e_pm_ready(adapter)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5736
		bool wake;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5737
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5738
		__e1000_shutdown(pdev, &wake, true);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5739
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5740
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5741
	return 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5742
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5743
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5744
static int e1000_idle(struct device *dev)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5745
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5746
	struct pci_dev *pdev = to_pci_dev(dev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5747
	struct net_device *netdev = pci_get_drvdata(pdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5748
	struct e1000_adapter *adapter = netdev_priv(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5749
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5750
	if (!e1000e_pm_ready(adapter))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5751
		return 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5752
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5753
	if (adapter->idle_check) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5754
		adapter->idle_check = false;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5755
		if (!e1000e_has_link(adapter))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5756
			pm_schedule_suspend(dev, MSEC_PER_SEC);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5757
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5758
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5759
	return -EBUSY;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5760
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5761
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5762
static int e1000_runtime_resume(struct device *dev)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5763
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5764
	struct pci_dev *pdev = to_pci_dev(dev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5765
	struct net_device *netdev = pci_get_drvdata(pdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5766
	struct e1000_adapter *adapter = netdev_priv(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5767
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5768
	if (!e1000e_pm_ready(adapter))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5769
		return 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5770
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5771
	adapter->idle_check = !dev->power.runtime_auto;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5772
	return __e1000_resume(pdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5773
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5774
#endif /* CONFIG_PM_RUNTIME */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5775
#endif /* CONFIG_PM */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5776
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5777
static void e1000_shutdown(struct pci_dev *pdev)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5778
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5779
	bool wake = false;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5780
	struct net_device *netdev = pci_get_drvdata(pdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5781
	struct e1000_adapter *adapter = netdev_priv(netdev);
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  5782
2406
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5783
	if (adapter->ecdev)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5784
		return;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5785
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5786
	__e1000_shutdown(pdev, &wake, false);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5787
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5788
	if (system_state == SYSTEM_POWER_OFF)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5789
		e1000_complete_shutdown(pdev, false, wake);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5790
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5791
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5792
#ifdef CONFIG_NET_POLL_CONTROLLER
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5793
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5794
static irqreturn_t e1000_intr_msix(int irq, void *data)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5795
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5796
	struct net_device *netdev = data;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5797
	struct e1000_adapter *adapter = netdev_priv(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5798
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5799
	if (adapter->msix_entries) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5800
		int vector, msix_irq;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5801
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5802
		vector = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5803
		msix_irq = adapter->msix_entries[vector].vector;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5804
		disable_irq(msix_irq);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5805
		e1000_intr_msix_rx(msix_irq, netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5806
		enable_irq(msix_irq);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5807
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5808
		vector++;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5809
		msix_irq = adapter->msix_entries[vector].vector;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5810
		disable_irq(msix_irq);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5811
		e1000_intr_msix_tx(msix_irq, netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5812
		enable_irq(msix_irq);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5813
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5814
		vector++;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5815
		msix_irq = adapter->msix_entries[vector].vector;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5816
		disable_irq(msix_irq);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5817
		e1000_msix_other(msix_irq, netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5818
		enable_irq(msix_irq);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5819
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5820
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5821
	return IRQ_HANDLED;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5822
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5823
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5824
/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5825
 * Polling 'interrupt' - used by things like netconsole to send skbs
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5826
 * without having to re-enable interrupts. It's not called while
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5827
 * the interrupt routine is executing.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5828
 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5829
static void e1000_netpoll(struct net_device *netdev)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5830
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5831
	struct e1000_adapter *adapter = netdev_priv(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5832
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5833
	switch (adapter->int_mode) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5834
	case E1000E_INT_MODE_MSIX:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5835
		e1000_intr_msix(adapter->pdev->irq, netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5836
		break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5837
	case E1000E_INT_MODE_MSI:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5838
		disable_irq(adapter->pdev->irq);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5839
		e1000_intr_msi(adapter->pdev->irq, netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5840
		enable_irq(adapter->pdev->irq);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5841
		break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5842
	default: /* E1000E_INT_MODE_LEGACY */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5843
		disable_irq(adapter->pdev->irq);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5844
		e1000_intr(adapter->pdev->irq, netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5845
		enable_irq(adapter->pdev->irq);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5846
		break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5847
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5848
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5849
#endif
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5850
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5851
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5852
 * e1000_io_error_detected - called when PCI error is detected
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5853
 * @pdev: Pointer to PCI device
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5854
 * @state: The current pci connection state
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5855
 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5856
 * This function is called after a PCI bus error affecting
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5857
 * this device has been detected.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5858
 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5859
static pci_ers_result_t e1000_io_error_detected(struct pci_dev *pdev,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5860
						pci_channel_state_t state)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5861
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5862
	struct net_device *netdev = pci_get_drvdata(pdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5863
	struct e1000_adapter *adapter = netdev_priv(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5864
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5865
	netif_device_detach(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5866
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5867
	if (state == pci_channel_io_perm_failure)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5868
		return PCI_ERS_RESULT_DISCONNECT;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5869
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5870
	if (netif_running(netdev))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5871
		e1000e_down(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5872
	pci_disable_device(pdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5873
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5874
	/* Request a slot slot reset. */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5875
	return PCI_ERS_RESULT_NEED_RESET;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5876
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5877
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5878
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5879
 * e1000_io_slot_reset - called after the pci bus has been reset.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5880
 * @pdev: Pointer to PCI device
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5881
 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5882
 * Restart the card from scratch, as if from a cold-boot. Implementation
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5883
 * resembles the first-half of the e1000_resume routine.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5884
 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5885
static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5886
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5887
	struct net_device *netdev = pci_get_drvdata(pdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5888
	struct e1000_adapter *adapter = netdev_priv(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5889
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5890
	u16 aspm_disable_flag = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5891
	int err;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5892
	pci_ers_result_t result;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5893
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5894
	if (adapter->flags2 & FLAG2_DISABLE_ASPM_L0S)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5895
		aspm_disable_flag = PCIE_LINK_STATE_L0S;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5896
	if (adapter->flags2 & FLAG2_DISABLE_ASPM_L1)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5897
		aspm_disable_flag |= PCIE_LINK_STATE_L1;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5898
	if (aspm_disable_flag)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5899
		e1000e_disable_aspm(pdev, aspm_disable_flag);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5900
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5901
	err = pci_enable_device_mem(pdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5902
	if (err) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5903
		dev_err(&pdev->dev,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5904
			"Cannot re-enable PCI device after reset.\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5905
		result = PCI_ERS_RESULT_DISCONNECT;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5906
	} else {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5907
		pci_set_master(pdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5908
		pdev->state_saved = true;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5909
		pci_restore_state(pdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5910
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5911
		pci_enable_wake(pdev, PCI_D3hot, 0);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5912
		pci_enable_wake(pdev, PCI_D3cold, 0);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5913
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5914
		e1000e_reset(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5915
		ew32(WUS, ~0);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5916
		result = PCI_ERS_RESULT_RECOVERED;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5917
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5918
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5919
	pci_cleanup_aer_uncorrect_error_status(pdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5920
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5921
	return result;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5922
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5923
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5924
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5925
 * e1000_io_resume - called when traffic can start flowing again.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5926
 * @pdev: Pointer to PCI device
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5927
 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5928
 * This callback is called when the error recovery driver tells us that
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5929
 * its OK to resume normal operation. Implementation resembles the
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5930
 * second-half of the e1000_resume routine.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5931
 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5932
static void e1000_io_resume(struct pci_dev *pdev)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5933
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5934
	struct net_device *netdev = pci_get_drvdata(pdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5935
	struct e1000_adapter *adapter = netdev_priv(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5936
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5937
	e1000_init_manageability_pt(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5938
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5939
	if (netif_running(netdev)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5940
		if (e1000e_up(adapter)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5941
			dev_err(&pdev->dev,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5942
				"can't bring device back up after reset\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5943
			return;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5944
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5945
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5946
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5947
	netif_device_attach(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5948
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5949
	/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5950
	 * If the controller has AMT, do not set DRV_LOAD until the interface
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5951
	 * is up.  For all other cases, let the f/w know that the h/w is now
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5952
	 * under the control of the driver.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5953
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5954
	if (!(adapter->flags & FLAG_HAS_AMT))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5955
		e1000e_get_hw_control(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5956
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5957
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5958
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5959
static void e1000_print_device_info(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5960
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5961
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5962
	struct net_device *netdev = adapter->netdev;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5963
	u32 ret_val;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5964
	u8 pba_str[E1000_PBANUM_LENGTH];
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5965
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5966
	/* print bus type/speed/width info */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5967
	e_info("(PCI Express:2.5GT/s:%s) %pM\n",
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5968
	       /* bus width */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5969
	       ((hw->bus.width == e1000_bus_width_pcie_x4) ? "Width x4" :
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5970
	        "Width x1"),
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5971
	       /* MAC address */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5972
	       netdev->dev_addr);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5973
	e_info("Intel(R) PRO/%s Network Connection\n",
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5974
	       (hw->phy.type == e1000_phy_ife) ? "10/100" : "1000");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5975
	ret_val = e1000_read_pba_string_generic(hw, pba_str,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5976
						E1000_PBANUM_LENGTH);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5977
	if (ret_val)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5978
		strncpy((char *)pba_str, "Unknown", sizeof(pba_str) - 1);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5979
	e_info("MAC: %d, PHY: %d, PBA No: %s\n",
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5980
	       hw->mac.type, hw->phy.type, pba_str);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5981
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5982
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5983
static void e1000_eeprom_checks(struct e1000_adapter *adapter)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5984
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5985
	struct e1000_hw *hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5986
	int ret_val;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5987
	u16 buf = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5988
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5989
	if (hw->mac.type != e1000_82573)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5990
		return;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5991
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5992
	ret_val = e1000_read_nvm(hw, NVM_INIT_CONTROL2_REG, 1, &buf);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5993
	if (!ret_val && (!(le16_to_cpu(buf) & (1 << 0)))) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5994
		/* Deep Smart Power Down (DSPD) */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5995
		dev_warn(&adapter->pdev->dev,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5996
			 "Warning: detected DSPD enabled in EEPROM\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5997
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5998
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5999
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6000
static int e1000_set_features(struct net_device *netdev, u32 features)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6001
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6002
	struct e1000_adapter *adapter = netdev_priv(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6003
	u32 changed = features ^ netdev->features;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6004
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6005
	if (changed & (NETIF_F_TSO | NETIF_F_TSO6))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6006
		adapter->flags |= FLAG_TSO_FORCE;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6007
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6008
	if (!(changed & (NETIF_F_HW_VLAN_RX | NETIF_F_HW_VLAN_TX |
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6009
			 NETIF_F_RXCSUM)))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6010
		return 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6011
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6012
	if (netif_running(netdev))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6013
		e1000e_reinit_locked(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6014
	else
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6015
		e1000e_reset(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6016
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6017
	return 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6018
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6019
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6020
static const struct net_device_ops e1000e_netdev_ops = {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6021
	.ndo_open		= e1000_open,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6022
	.ndo_stop		= e1000_close,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6023
	.ndo_start_xmit		= e1000_xmit_frame,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6024
	.ndo_get_stats64	= e1000e_get_stats64,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6025
	.ndo_set_rx_mode	= e1000_set_multi,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6026
	.ndo_set_mac_address	= e1000_set_mac,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6027
	.ndo_change_mtu		= e1000_change_mtu,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6028
	.ndo_do_ioctl		= e1000_ioctl,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6029
	.ndo_tx_timeout		= e1000_tx_timeout,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6030
	.ndo_validate_addr	= eth_validate_addr,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6031
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6032
	.ndo_vlan_rx_add_vid	= e1000_vlan_rx_add_vid,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6033
	.ndo_vlan_rx_kill_vid	= e1000_vlan_rx_kill_vid,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6034
#ifdef CONFIG_NET_POLL_CONTROLLER
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6035
	.ndo_poll_controller	= e1000_netpoll,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6036
#endif
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6037
	.ndo_set_features = e1000_set_features,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6038
};
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6039
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6040
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6041
 * ec_poll - Ethercat poll Routine
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6042
 * @netdev: net device structure
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6043
 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6044
 * This function can never fail.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6045
 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6046
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6047
void ec_poll(struct net_device *netdev)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6048
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6049
	struct e1000_adapter *adapter = netdev_priv(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6050
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6051
	if (jiffies - adapter->ec_watchdog_jiffies >= 2 * HZ) {
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  6052
		struct e1000_hw *hw = &adapter->hw;
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  6053
		hw->mac.get_link_status = true;
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  6054
		e1000_watchdog_task(&adapter->watchdog_task);
2406
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6055
		adapter->ec_watchdog_jiffies = jiffies;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6056
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6057
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6058
#ifdef CONFIG_PCI_MSI
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  6059
	e1000_intr_msi(0, netdev);
2406
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6060
#else
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  6061
	e1000_intr(0, netdev);
2406
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6062
#endif
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6063
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6064
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6065
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6066
 * e1000_probe - Device Initialization Routine
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6067
 * @pdev: PCI device information struct
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6068
 * @ent: entry in e1000_pci_tbl
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6069
 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6070
 * Returns 0 on success, negative on failure
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6071
 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6072
 * e1000_probe initializes an adapter identified by a pci_dev structure.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6073
 * The OS initialization, configuring of the adapter private structure,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6074
 * and a hardware reset occur.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6075
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6076
static int __devinit e1000_probe(struct pci_dev *pdev,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6077
				 const struct pci_device_id *ent)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6078
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6079
	struct net_device *netdev;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6080
	struct e1000_adapter *adapter;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6081
	struct e1000_hw *hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6082
	const struct e1000_info *ei = e1000_info_tbl[ent->driver_data];
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6083
	resource_size_t mmio_start, mmio_len;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6084
	resource_size_t flash_start, flash_len;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6085
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6086
	static int cards_found;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6087
	u16 aspm_disable_flag = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6088
	int i, err, pci_using_dac;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6089
	u16 eeprom_data = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6090
	u16 eeprom_apme_mask = E1000_EEPROM_APME;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6091
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6092
	if (ei->flags2 & FLAG2_DISABLE_ASPM_L0S)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6093
		aspm_disable_flag = PCIE_LINK_STATE_L0S;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6094
	if (ei->flags2 & FLAG2_DISABLE_ASPM_L1)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6095
		aspm_disable_flag |= PCIE_LINK_STATE_L1;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6096
	if (aspm_disable_flag)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6097
		e1000e_disable_aspm(pdev, aspm_disable_flag);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6098
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6099
	err = pci_enable_device_mem(pdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6100
	if (err)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6101
		return err;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6102
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6103
	pci_using_dac = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6104
	err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(64));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6105
	if (!err) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6106
		err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6107
		if (!err)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6108
			pci_using_dac = 1;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6109
	} else {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6110
		err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6111
		if (err) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6112
			err = dma_set_coherent_mask(&pdev->dev,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6113
						    DMA_BIT_MASK(32));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6114
			if (err) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6115
				dev_err(&pdev->dev, "No usable DMA "
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6116
					"configuration, aborting\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6117
				goto err_dma;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6118
			}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6119
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6120
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6121
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6122
	err = pci_request_selected_regions_exclusive(pdev,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6123
	                                  pci_select_bars(pdev, IORESOURCE_MEM),
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6124
	                                  e1000e_driver_name);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6125
	if (err)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6126
		goto err_pci_reg;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6127
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6128
	/* AER (Advanced Error Reporting) hooks */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6129
	pci_enable_pcie_error_reporting(pdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6130
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6131
	pci_set_master(pdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6132
	/* PCI config space info */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6133
	err = pci_save_state(pdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6134
	if (err)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6135
		goto err_alloc_etherdev;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6136
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6137
	err = -ENOMEM;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6138
	netdev = alloc_etherdev(sizeof(struct e1000_adapter));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6139
	if (!netdev)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6140
		goto err_alloc_etherdev;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6141
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6142
	SET_NETDEV_DEV(netdev, &pdev->dev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6143
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6144
	netdev->irq = pdev->irq;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6145
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6146
	pci_set_drvdata(pdev, netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6147
	adapter = netdev_priv(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6148
	hw = &adapter->hw;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6149
	adapter->netdev = netdev;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6150
	adapter->pdev = pdev;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6151
	adapter->ei = ei;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6152
	adapter->pba = ei->pba;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6153
	adapter->flags = ei->flags;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6154
	adapter->flags2 = ei->flags2;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6155
	adapter->hw.adapter = adapter;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6156
	adapter->hw.mac.type = ei->mac;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6157
	adapter->max_hw_frame_size = ei->max_hw_frame_size;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6158
	adapter->msg_enable = (1 << NETIF_MSG_DRV | NETIF_MSG_PROBE) - 1;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6159
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6160
	mmio_start = pci_resource_start(pdev, 0);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6161
	mmio_len = pci_resource_len(pdev, 0);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6162
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6163
	err = -EIO;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6164
	adapter->hw.hw_addr = ioremap(mmio_start, mmio_len);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6165
	if (!adapter->hw.hw_addr)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6166
		goto err_ioremap;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6167
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6168
	if ((adapter->flags & FLAG_HAS_FLASH) &&
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6169
	    (pci_resource_flags(pdev, 1) & IORESOURCE_MEM)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6170
		flash_start = pci_resource_start(pdev, 1);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6171
		flash_len = pci_resource_len(pdev, 1);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6172
		adapter->hw.flash_address = ioremap(flash_start, flash_len);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6173
		if (!adapter->hw.flash_address)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6174
			goto err_flashmap;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6175
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6176
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6177
	/* construct the net_device struct */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6178
	netdev->netdev_ops		= &e1000e_netdev_ops;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6179
	e1000e_set_ethtool_ops(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6180
	netdev->watchdog_timeo		= 5 * HZ;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6181
	netif_napi_add(netdev, &adapter->napi, e1000_clean, 64);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6182
	strncpy(netdev->name, pci_name(pdev), sizeof(netdev->name) - 1);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6183
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6184
	netdev->mem_start = mmio_start;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6185
	netdev->mem_end = mmio_start + mmio_len;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6186
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6187
	adapter->bd_number = cards_found++;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6188
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6189
	e1000e_check_options(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6190
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6191
	/* setup adapter struct */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6192
	err = e1000_sw_init(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6193
	if (err)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6194
		goto err_sw_init;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6195
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6196
	memcpy(&hw->mac.ops, ei->mac_ops, sizeof(hw->mac.ops));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6197
	memcpy(&hw->nvm.ops, ei->nvm_ops, sizeof(hw->nvm.ops));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6198
	memcpy(&hw->phy.ops, ei->phy_ops, sizeof(hw->phy.ops));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6199
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6200
	err = ei->get_variants(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6201
	if (err)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6202
		goto err_hw_init;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6203
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6204
	if ((adapter->flags & FLAG_IS_ICH) &&
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6205
	    (adapter->flags & FLAG_READ_ONLY_NVM))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6206
		e1000e_write_protect_nvm_ich8lan(&adapter->hw);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6207
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6208
	hw->mac.ops.get_bus_info(&adapter->hw);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6209
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6210
	adapter->hw.phy.autoneg_wait_to_complete = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6211
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6212
	/* Copper options */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6213
	if (adapter->hw.phy.media_type == e1000_media_type_copper) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6214
		adapter->hw.phy.mdix = AUTO_ALL_MODES;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6215
		adapter->hw.phy.disable_polarity_correction = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6216
		adapter->hw.phy.ms_type = e1000_ms_hw_default;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6217
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6218
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6219
	if (e1000_check_reset_block(&adapter->hw))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6220
		e_info("PHY reset is blocked due to SOL/IDER session.\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6221
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6222
	/* Set initial default active device features */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6223
	netdev->features = (NETIF_F_SG |
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6224
			    NETIF_F_HW_VLAN_RX |
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6225
			    NETIF_F_HW_VLAN_TX |
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6226
			    NETIF_F_TSO |
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6227
			    NETIF_F_TSO6 |
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6228
			    NETIF_F_RXCSUM |
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6229
			    NETIF_F_HW_CSUM);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6230
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6231
	/* Set user-changeable features (subset of all device features) */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6232
	netdev->hw_features = netdev->features;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6233
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6234
	if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6235
		netdev->features |= NETIF_F_HW_VLAN_FILTER;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6236
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6237
	netdev->vlan_features |= (NETIF_F_SG |
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6238
				  NETIF_F_TSO |
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6239
				  NETIF_F_TSO6 |
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6240
				  NETIF_F_HW_CSUM);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6241
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6242
	if (pci_using_dac) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6243
		netdev->features |= NETIF_F_HIGHDMA;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6244
		netdev->vlan_features |= NETIF_F_HIGHDMA;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6245
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6246
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6247
	if (e1000e_enable_mng_pass_thru(&adapter->hw))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6248
		adapter->flags |= FLAG_MNG_PT_ENABLED;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6249
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6250
	/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6251
	 * before reading the NVM, reset the controller to
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6252
	 * put the device in a known good starting state
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6253
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6254
	adapter->hw.mac.ops.reset_hw(&adapter->hw);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6255
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6256
	/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6257
	 * systems with ASPM and others may see the checksum fail on the first
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6258
	 * attempt. Let's give it a few tries
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6259
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6260
	for (i = 0;; i++) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6261
		if (e1000_validate_nvm_checksum(&adapter->hw) >= 0)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6262
			break;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6263
		if (i == 2) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6264
			e_err("The NVM Checksum Is Not Valid\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6265
			err = -EIO;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6266
			goto err_eeprom;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6267
		}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6268
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6269
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6270
	e1000_eeprom_checks(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6271
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6272
	/* copy the MAC address */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6273
	if (e1000e_read_mac_addr(&adapter->hw))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6274
		e_err("NVM Read Error while reading MAC address\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6275
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6276
	memcpy(netdev->dev_addr, adapter->hw.mac.addr, netdev->addr_len);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6277
	memcpy(netdev->perm_addr, adapter->hw.mac.addr, netdev->addr_len);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6278
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6279
	if (!is_valid_ether_addr(netdev->perm_addr)) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6280
		e_err("Invalid MAC Address: %pM\n", netdev->perm_addr);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6281
		err = -EIO;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6282
		goto err_eeprom;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6283
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6284
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6285
	init_timer(&adapter->watchdog_timer);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6286
	adapter->watchdog_timer.function = e1000_watchdog;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6287
	adapter->watchdog_timer.data = (unsigned long) adapter;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6288
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6289
	init_timer(&adapter->phy_info_timer);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6290
	adapter->phy_info_timer.function = e1000_update_phy_info;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6291
	adapter->phy_info_timer.data = (unsigned long) adapter;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6292
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6293
	INIT_WORK(&adapter->reset_task, e1000_reset_task);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6294
	INIT_WORK(&adapter->watchdog_task, e1000_watchdog_task);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6295
	INIT_WORK(&adapter->downshift_task, e1000e_downshift_workaround);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6296
	INIT_WORK(&adapter->update_phy_task, e1000e_update_phy_task);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6297
	INIT_WORK(&adapter->print_hang_task, e1000_print_hw_hang);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6298
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6299
	/* Initialize link parameters. User can change them with ethtool */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6300
	adapter->hw.mac.autoneg = 1;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6301
	adapter->fc_autoneg = 1;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6302
	adapter->hw.fc.requested_mode = e1000_fc_default;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6303
	adapter->hw.fc.current_mode = e1000_fc_default;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6304
	adapter->hw.phy.autoneg_advertised = 0x2f;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6305
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6306
	/* ring size defaults */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6307
	adapter->rx_ring->count = 256;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6308
	adapter->tx_ring->count = 256;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6309
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6310
	/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6311
	 * Initial Wake on LAN setting - If APM wake is enabled in
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6312
	 * the EEPROM, enable the ACPI Magic Packet filter
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6313
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6314
	if (adapter->flags & FLAG_APME_IN_WUC) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6315
		/* APME bit in EEPROM is mapped to WUC.APME */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6316
		eeprom_data = er32(WUC);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6317
		eeprom_apme_mask = E1000_WUC_APME;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6318
		if ((hw->mac.type > e1000_ich10lan) &&
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6319
		    (eeprom_data & E1000_WUC_PHY_WAKE))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6320
			adapter->flags2 |= FLAG2_HAS_PHY_WAKEUP;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6321
	} else if (adapter->flags & FLAG_APME_IN_CTRL3) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6322
		if (adapter->flags & FLAG_APME_CHECK_PORT_B &&
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6323
		    (adapter->hw.bus.func == 1))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6324
			e1000_read_nvm(&adapter->hw,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6325
				NVM_INIT_CONTROL3_PORT_B, 1, &eeprom_data);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6326
		else
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6327
			e1000_read_nvm(&adapter->hw,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6328
				NVM_INIT_CONTROL3_PORT_A, 1, &eeprom_data);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6329
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6330
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6331
	/* fetch WoL from EEPROM */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6332
	if (eeprom_data & eeprom_apme_mask)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6333
		adapter->eeprom_wol |= E1000_WUFC_MAG;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6334
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6335
	/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6336
	 * now that we have the eeprom settings, apply the special cases
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6337
	 * where the eeprom may be wrong or the board simply won't support
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6338
	 * wake on lan on a particular port
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6339
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6340
	if (!(adapter->flags & FLAG_HAS_WOL))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6341
		adapter->eeprom_wol = 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6342
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6343
	/* initialize the wol settings based on the eeprom settings */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6344
	adapter->wol = adapter->eeprom_wol;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6345
	device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6346
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6347
	/* save off EEPROM version number */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6348
	e1000_read_nvm(&adapter->hw, 5, 1, &adapter->eeprom_vers);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6349
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6350
	/* reset the hardware with the new settings */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6351
	e1000e_reset(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6352
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6353
	/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6354
	 * If the controller has AMT, do not set DRV_LOAD until the interface
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6355
	 * is up.  For all other cases, let the f/w know that the h/w is now
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6356
	 * under the control of the driver.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6357
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6358
	if (!(adapter->flags & FLAG_HAS_AMT))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6359
		e1000e_get_hw_control(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6360
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6361
	adapter->ecdev = ecdev_offer(netdev, ec_poll, THIS_MODULE);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6362
	if (adapter->ecdev) {
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  6363
		err = ecdev_open(adapter->ecdev);
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  6364
		if (err) {
2406
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6365
			ecdev_withdraw(adapter->ecdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6366
			goto err_register;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6367
		}
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2406
diff changeset
  6368
		adapter->ec_watchdog_jiffies = jiffies;
2406
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6369
	} else {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6370
		strncpy(netdev->name, "eth%d", sizeof(netdev->name) - 1);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6371
		err = register_netdev(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6372
		if (err)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6373
			goto err_register;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6374
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6375
		/* carrier off reporting is important to ethtool even BEFORE open */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6376
		netif_carrier_off(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6377
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6378
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6379
	e1000_print_device_info(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6380
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6381
	if (pci_dev_run_wake(pdev))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6382
		pm_runtime_put_noidle(&pdev->dev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6383
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6384
	return 0;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6385
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6386
err_register:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6387
	if (!(adapter->flags & FLAG_HAS_AMT))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6388
		e1000e_release_hw_control(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6389
err_eeprom:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6390
	if (!e1000_check_reset_block(&adapter->hw))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6391
		e1000_phy_hw_reset(&adapter->hw);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6392
err_hw_init:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6393
	kfree(adapter->tx_ring);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6394
	kfree(adapter->rx_ring);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6395
err_sw_init:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6396
	if (adapter->hw.flash_address)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6397
		iounmap(adapter->hw.flash_address);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6398
	e1000e_reset_interrupt_capability(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6399
err_flashmap:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6400
	iounmap(adapter->hw.hw_addr);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6401
err_ioremap:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6402
	free_netdev(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6403
err_alloc_etherdev:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6404
	pci_release_selected_regions(pdev,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6405
	                             pci_select_bars(pdev, IORESOURCE_MEM));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6406
err_pci_reg:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6407
err_dma:
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6408
	pci_disable_device(pdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6409
	return err;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6410
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6411
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6412
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6413
 * e1000_remove - Device Removal Routine
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6414
 * @pdev: PCI device information struct
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6415
 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6416
 * e1000_remove is called by the PCI subsystem to alert the driver
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6417
 * that it should release a PCI device.  The could be caused by a
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6418
 * Hot-Plug event, or because the driver is going to be removed from
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6419
 * memory.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6420
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6421
static void __devexit e1000_remove(struct pci_dev *pdev)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6422
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6423
	struct net_device *netdev = pci_get_drvdata(pdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6424
	struct e1000_adapter *adapter = netdev_priv(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6425
	bool down = test_bit(__E1000_DOWN, &adapter->state);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6426
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6427
	/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6428
	 * The timers may be rescheduled, so explicitly disable them
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6429
	 * from being rescheduled.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6430
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6431
	if (!down)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6432
		set_bit(__E1000_DOWN, &adapter->state);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6433
	del_timer_sync(&adapter->watchdog_timer);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6434
	del_timer_sync(&adapter->phy_info_timer);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6435
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6436
	cancel_work_sync(&adapter->reset_task);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6437
	cancel_work_sync(&adapter->watchdog_task);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6438
	cancel_work_sync(&adapter->downshift_task);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6439
	cancel_work_sync(&adapter->update_phy_task);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6440
	cancel_work_sync(&adapter->print_hang_task);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6441
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6442
	if (!(netdev->flags & IFF_UP))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6443
		e1000_power_down_phy(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6444
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6445
	/* Don't lie to e1000_close() down the road. */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6446
	if (!down)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6447
		clear_bit(__E1000_DOWN, &adapter->state);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6448
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6449
	if (adapter->ecdev) {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6450
		ecdev_close(adapter->ecdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6451
		ecdev_withdraw(adapter->ecdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6452
	} else {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6453
		unregister_netdev(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6454
	}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6455
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6456
	if (pci_dev_run_wake(pdev))
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6457
		pm_runtime_get_noresume(&pdev->dev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6458
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6459
	/*
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6460
	 * Release control of h/w to f/w.  If f/w is AMT enabled, this
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6461
	 * would have already happened in close and is redundant.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6462
	 */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6463
	e1000e_release_hw_control(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6464
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6465
	e1000e_reset_interrupt_capability(adapter);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6466
	kfree(adapter->tx_ring);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6467
	kfree(adapter->rx_ring);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6468
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6469
	iounmap(adapter->hw.hw_addr);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6470
	if (adapter->hw.flash_address)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6471
		iounmap(adapter->hw.flash_address);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6472
	pci_release_selected_regions(pdev,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6473
	                             pci_select_bars(pdev, IORESOURCE_MEM));
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6474
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6475
	free_netdev(netdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6476
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6477
	/* AER disable */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6478
	pci_disable_pcie_error_reporting(pdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6479
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6480
	pci_disable_device(pdev);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6481
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6482
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6483
/* PCI Error Recovery (ERS) */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6484
static struct pci_error_handlers e1000_err_handler = {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6485
	.error_detected = e1000_io_error_detected,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6486
	.slot_reset = e1000_io_slot_reset,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6487
	.resume = e1000_io_resume,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6488
};
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6489
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6490
static DEFINE_PCI_DEVICE_TABLE(e1000_pci_tbl) = {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6491
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_COPPER), board_82571 },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6492
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_FIBER), board_82571 },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6493
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_QUAD_COPPER), board_82571 },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6494
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_QUAD_COPPER_LP), board_82571 },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6495
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_QUAD_FIBER), board_82571 },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6496
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_SERDES), board_82571 },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6497
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_SERDES_DUAL), board_82571 },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6498
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_SERDES_QUAD), board_82571 },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6499
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82571PT_QUAD_COPPER), board_82571 },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6500
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6501
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82572EI), board_82572 },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6502
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82572EI_COPPER), board_82572 },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6503
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82572EI_FIBER), board_82572 },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6504
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82572EI_SERDES), board_82572 },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6505
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6506
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82573E), board_82573 },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6507
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82573E_IAMT), board_82573 },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6508
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82573L), board_82573 },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6509
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6510
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82574L), board_82574 },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6511
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82574LA), board_82574 },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6512
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82583V), board_82583 },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6513
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6514
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_80003ES2LAN_COPPER_DPT),
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6515
	  board_80003es2lan },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6516
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_80003ES2LAN_COPPER_SPT),
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6517
	  board_80003es2lan },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6518
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_80003ES2LAN_SERDES_DPT),
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6519
	  board_80003es2lan },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6520
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_80003ES2LAN_SERDES_SPT),
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6521
	  board_80003es2lan },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6522
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6523
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH8_IFE), board_ich8lan },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6524
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH8_IFE_G), board_ich8lan },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6525
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH8_IFE_GT), board_ich8lan },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6526
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH8_IGP_AMT), board_ich8lan },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6527
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH8_IGP_C), board_ich8lan },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6528
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH8_IGP_M), board_ich8lan },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6529
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH8_IGP_M_AMT), board_ich8lan },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6530
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH8_82567V_3), board_ich8lan },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6531
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6532
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IFE), board_ich9lan },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6533
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IFE_G), board_ich9lan },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6534
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IFE_GT), board_ich9lan },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6535
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IGP_AMT), board_ich9lan },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6536
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IGP_C), board_ich9lan },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6537
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_BM), board_ich9lan },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6538
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IGP_M), board_ich9lan },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6539
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IGP_M_AMT), board_ich9lan },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6540
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IGP_M_V), board_ich9lan },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6541
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6542
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH10_R_BM_LM), board_ich9lan },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6543
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH10_R_BM_LF), board_ich9lan },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6544
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH10_R_BM_V), board_ich9lan },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6545
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6546
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH10_D_BM_LM), board_ich10lan },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6547
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH10_D_BM_LF), board_ich10lan },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6548
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH10_D_BM_V), board_ich10lan },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6549
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6550
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_M_HV_LM), board_pchlan },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6551
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_M_HV_LC), board_pchlan },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6552
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_D_HV_DM), board_pchlan },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6553
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_D_HV_DC), board_pchlan },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6554
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6555
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH2_LV_LM), board_pch2lan },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6556
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH2_LV_V), board_pch2lan },
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6557
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6558
	{ }	/* terminate list */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6559
};
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6560
//MODULE_DEVICE_TABLE(pci, e1000_pci_tbl);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6561
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6562
#ifdef CONFIG_PM
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6563
static const struct dev_pm_ops e1000_pm_ops = {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6564
	SET_SYSTEM_SLEEP_PM_OPS(e1000_suspend, e1000_resume)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6565
	SET_RUNTIME_PM_OPS(e1000_runtime_suspend,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6566
				e1000_runtime_resume, e1000_idle)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6567
};
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6568
#endif
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6569
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6570
/* PCI Device API Driver */
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6571
static struct pci_driver e1000_driver = {
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6572
	.name     = e1000e_driver_name,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6573
	.id_table = e1000_pci_tbl,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6574
	.probe    = e1000_probe,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6575
	.remove   = __devexit_p(e1000_remove),
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6576
#ifdef CONFIG_PM
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6577
	.driver.pm = &e1000_pm_ops,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6578
#endif
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6579
	.shutdown = e1000_shutdown,
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6580
	.err_handler = &e1000_err_handler
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6581
};
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6582
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6583
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6584
 * e1000_init_module - Driver Registration Routine
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6585
 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6586
 * e1000_init_module is the first routine called when the driver is
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6587
 * loaded. All it does is register with the PCI subsystem.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6588
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6589
static int __init e1000_init_module(void)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6590
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6591
	int ret;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6592
	pr_info("EtherCAT-capable Intel(R) PRO/1000 Network Driver - %s\n",
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6593
		e1000e_driver_version);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6594
	pr_info("Copyright(c) 1999 - 2011 Intel Corporation.\n");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6595
	ret = pci_register_driver(&e1000_driver);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6596
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6597
	return ret;
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6598
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6599
module_init(e1000_init_module);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6600
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6601
/**
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6602
 * e1000_exit_module - Driver Exit Cleanup Routine
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6603
 *
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6604
 * e1000_exit_module is called just before the driver is removed
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6605
 * from memory.
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6606
 **/
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6607
static void __exit e1000_exit_module(void)
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6608
{
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6609
	pci_unregister_driver(&e1000_driver);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6610
}
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6611
module_exit(e1000_exit_module);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6612
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6613
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6614
MODULE_AUTHOR("Intel Corporation, <linux.nics@intel.com>");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6615
MODULE_DESCRIPTION("Ethercat-capable Intel(R) PRO/1000 Network Driver");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6616
MODULE_LICENSE("GPL");
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6617
MODULE_VERSION(DRV_VERSION);
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6618
fee219bb31a9 Added e1000e driver for kernel 3.2, thanks to J. Kunz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6619
/* e1000_main.c */