devices/e1000e/netdev-3.8-orig.c
author Patrick Bruenn <p.bruenn@beckhoff.com>
Tue, 12 Apr 2016 11:17:36 +0200
branchstable-1.5
changeset 2654 b3f6b3e5ef29
parent 2584 0e3d989ff233
permissions -rw-r--r--
devices/ccat: revert "limit rx processing to one frame per poll"

revert "limit rx processing to one frame per poll", which caused etherlab
frame timeouts in setups with more than one frame per cycle.
2584
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/*******************************************************************************
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
  Intel PRO/1000 Linux driver
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
  Copyright(c) 1999 - 2012 Intel Corporation.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     5
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     6
  This program is free software; you can redistribute it and/or modify it
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     7
  under the terms and conditions of the GNU General Public License,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
  version 2, as published by the Free Software Foundation.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     9
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    10
  This program is distributed in the hope it will be useful, but WITHOUT
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    11
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    12
  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
  more details.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    14
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    15
  You should have received a copy of the GNU General Public License along with
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    16
  this program; if not, write to the Free Software Foundation, Inc.,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    17
  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    18
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    19
  The full GNU General Public License is included in this distribution in
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    20
  the file called "COPYING".
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    21
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    22
  Contact Information:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    23
  Linux NICS <linux.nics@intel.com>
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    24
  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    25
  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    26
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    27
*******************************************************************************/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    28
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
#include <linux/module.h>
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
#include <linux/types.h>
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
#include <linux/init.h>
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
#include <linux/pci.h>
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
#include <linux/vmalloc.h>
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
#include <linux/pagemap.h>
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
#include <linux/delay.h>
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
#include <linux/netdevice.h>
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    39
#include <linux/interrupt.h>
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
#include <linux/tcp.h>
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
#include <linux/ipv6.h>
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
#include <linux/slab.h>
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
#include <net/checksum.h>
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
#include <net/ip6_checksum.h>
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
#include <linux/mii.h>
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
#include <linux/ethtool.h>
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
#include <linux/if_vlan.h>
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    48
#include <linux/cpu.h>
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    49
#include <linux/smp.h>
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    50
#include <linux/pm_qos.h>
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    51
#include <linux/pm_runtime.h>
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    52
#include <linux/aer.h>
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    53
#include <linux/prefetch.h>
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    54
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    55
#include "e1000.h"
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    56
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    57
#define DRV_EXTRAVERSION "-k"
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    58
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    59
#define DRV_VERSION "2.1.4" DRV_EXTRAVERSION
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    60
char e1000e_driver_name[] = "e1000e";
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    61
const char e1000e_driver_version[] = DRV_VERSION;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    62
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    63
#define DEFAULT_MSG_ENABLE (NETIF_MSG_DRV|NETIF_MSG_PROBE|NETIF_MSG_LINK)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    64
static int debug = -1;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    65
module_param(debug, int, 0);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    66
MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    67
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    68
static void e1000e_disable_aspm(struct pci_dev *pdev, u16 state);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    69
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    70
static const struct e1000_info *e1000_info_tbl[] = {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    71
	[board_82571]		= &e1000_82571_info,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    72
	[board_82572]		= &e1000_82572_info,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    73
	[board_82573]		= &e1000_82573_info,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    74
	[board_82574]		= &e1000_82574_info,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    75
	[board_82583]		= &e1000_82583_info,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    76
	[board_80003es2lan]	= &e1000_es2_info,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    77
	[board_ich8lan]		= &e1000_ich8_info,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    78
	[board_ich9lan]		= &e1000_ich9_info,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    79
	[board_ich10lan]	= &e1000_ich10_info,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    80
	[board_pchlan]		= &e1000_pch_info,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    81
	[board_pch2lan]		= &e1000_pch2_info,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    82
	[board_pch_lpt]		= &e1000_pch_lpt_info,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    83
};
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    84
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    85
struct e1000_reg_info {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    86
	u32 ofs;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    87
	char *name;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    88
};
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    89
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    90
#define E1000_RDFH	0x02410	/* Rx Data FIFO Head - RW */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    91
#define E1000_RDFT	0x02418	/* Rx Data FIFO Tail - RW */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    92
#define E1000_RDFHS	0x02420	/* Rx Data FIFO Head Saved - RW */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    93
#define E1000_RDFTS	0x02428	/* Rx Data FIFO Tail Saved - RW */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    94
#define E1000_RDFPC	0x02430	/* Rx Data FIFO Packet Count - RW */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    95
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    96
#define E1000_TDFH	0x03410	/* Tx Data FIFO Head - RW */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    97
#define E1000_TDFT	0x03418	/* Tx Data FIFO Tail - RW */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    98
#define E1000_TDFHS	0x03420	/* Tx Data FIFO Head Saved - RW */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    99
#define E1000_TDFTS	0x03428	/* Tx Data FIFO Tail Saved - RW */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   100
#define E1000_TDFPC	0x03430	/* Tx Data FIFO Packet Count - RW */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   101
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   102
static const struct e1000_reg_info e1000_reg_info_tbl[] = {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   103
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   104
	/* General Registers */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   105
	{E1000_CTRL, "CTRL"},
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   106
	{E1000_STATUS, "STATUS"},
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   107
	{E1000_CTRL_EXT, "CTRL_EXT"},
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   108
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   109
	/* Interrupt Registers */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   110
	{E1000_ICR, "ICR"},
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   111
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   112
	/* Rx Registers */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   113
	{E1000_RCTL, "RCTL"},
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   114
	{E1000_RDLEN(0), "RDLEN"},
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   115
	{E1000_RDH(0), "RDH"},
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   116
	{E1000_RDT(0), "RDT"},
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   117
	{E1000_RDTR, "RDTR"},
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   118
	{E1000_RXDCTL(0), "RXDCTL"},
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   119
	{E1000_ERT, "ERT"},
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   120
	{E1000_RDBAL(0), "RDBAL"},
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   121
	{E1000_RDBAH(0), "RDBAH"},
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   122
	{E1000_RDFH, "RDFH"},
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   123
	{E1000_RDFT, "RDFT"},
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   124
	{E1000_RDFHS, "RDFHS"},
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   125
	{E1000_RDFTS, "RDFTS"},
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   126
	{E1000_RDFPC, "RDFPC"},
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   127
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   128
	/* Tx Registers */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   129
	{E1000_TCTL, "TCTL"},
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   130
	{E1000_TDBAL(0), "TDBAL"},
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   131
	{E1000_TDBAH(0), "TDBAH"},
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   132
	{E1000_TDLEN(0), "TDLEN"},
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   133
	{E1000_TDH(0), "TDH"},
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   134
	{E1000_TDT(0), "TDT"},
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   135
	{E1000_TIDV, "TIDV"},
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   136
	{E1000_TXDCTL(0), "TXDCTL"},
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   137
	{E1000_TADV, "TADV"},
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   138
	{E1000_TARC(0), "TARC"},
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   139
	{E1000_TDFH, "TDFH"},
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   140
	{E1000_TDFT, "TDFT"},
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   141
	{E1000_TDFHS, "TDFHS"},
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   142
	{E1000_TDFTS, "TDFTS"},
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   143
	{E1000_TDFPC, "TDFPC"},
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   144
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   145
	/* List Terminator */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   146
	{0, NULL}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   147
};
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   148
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   149
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   150
 * e1000_regdump - register printout routine
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   151
 * @hw: pointer to the HW structure
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   152
 * @reginfo: pointer to the register info table
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   153
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   154
static void e1000_regdump(struct e1000_hw *hw, struct e1000_reg_info *reginfo)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   155
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   156
	int n = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   157
	char rname[16];
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   158
	u32 regs[8];
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   159
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   160
	switch (reginfo->ofs) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   161
	case E1000_RXDCTL(0):
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   162
		for (n = 0; n < 2; n++)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   163
			regs[n] = __er32(hw, E1000_RXDCTL(n));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   164
		break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   165
	case E1000_TXDCTL(0):
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   166
		for (n = 0; n < 2; n++)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   167
			regs[n] = __er32(hw, E1000_TXDCTL(n));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   168
		break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   169
	case E1000_TARC(0):
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   170
		for (n = 0; n < 2; n++)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   171
			regs[n] = __er32(hw, E1000_TARC(n));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   172
		break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   173
	default:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   174
		pr_info("%-15s %08x\n",
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   175
			reginfo->name, __er32(hw, reginfo->ofs));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   176
		return;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   177
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   178
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   179
	snprintf(rname, 16, "%s%s", reginfo->name, "[0-1]");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   180
	pr_info("%-15s %08x %08x\n", rname, regs[0], regs[1]);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   181
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   182
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   183
static void e1000e_dump_ps_pages(struct e1000_adapter *adapter,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   184
				 struct e1000_buffer *bi)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   185
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   186
	int i;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   187
	struct e1000_ps_page *ps_page;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   188
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   189
	for (i = 0; i < adapter->rx_ps_pages; i++) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   190
		ps_page = &bi->ps_pages[i];
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   191
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   192
		if (ps_page->page) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   193
			pr_info("packet dump for ps_page %d:\n", i);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   194
			print_hex_dump(KERN_INFO, "", DUMP_PREFIX_ADDRESS,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   195
				       16, 1, page_address(ps_page->page),
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   196
				       PAGE_SIZE, true);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   197
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   198
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   199
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   200
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   201
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   202
 * e1000e_dump - Print registers, Tx-ring and Rx-ring
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   203
 * @adapter: board private structure
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   204
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   205
static void e1000e_dump(struct e1000_adapter *adapter)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   206
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   207
	struct net_device *netdev = adapter->netdev;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   208
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   209
	struct e1000_reg_info *reginfo;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   210
	struct e1000_ring *tx_ring = adapter->tx_ring;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   211
	struct e1000_tx_desc *tx_desc;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   212
	struct my_u0 {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   213
		__le64 a;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   214
		__le64 b;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   215
	} *u0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   216
	struct e1000_buffer *buffer_info;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   217
	struct e1000_ring *rx_ring = adapter->rx_ring;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   218
	union e1000_rx_desc_packet_split *rx_desc_ps;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   219
	union e1000_rx_desc_extended *rx_desc;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   220
	struct my_u1 {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   221
		__le64 a;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   222
		__le64 b;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   223
		__le64 c;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   224
		__le64 d;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   225
	} *u1;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   226
	u32 staterr;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   227
	int i = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   228
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   229
	if (!netif_msg_hw(adapter))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   230
		return;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   231
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   232
	/* Print netdevice Info */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   233
	if (netdev) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   234
		dev_info(&adapter->pdev->dev, "Net device Info\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   235
		pr_info("Device Name     state            trans_start      last_rx\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   236
		pr_info("%-15s %016lX %016lX %016lX\n",
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   237
			netdev->name, netdev->state, netdev->trans_start,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   238
			netdev->last_rx);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   239
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   240
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   241
	/* Print Registers */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   242
	dev_info(&adapter->pdev->dev, "Register Dump\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   243
	pr_info(" Register Name   Value\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   244
	for (reginfo = (struct e1000_reg_info *)e1000_reg_info_tbl;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   245
	     reginfo->name; reginfo++) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   246
		e1000_regdump(hw, reginfo);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   247
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   248
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   249
	/* Print Tx Ring Summary */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   250
	if (!netdev || !netif_running(netdev))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   251
		return;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   252
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   253
	dev_info(&adapter->pdev->dev, "Tx Ring Summary\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   254
	pr_info("Queue [NTU] [NTC] [bi(ntc)->dma  ] leng ntw timestamp\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   255
	buffer_info = &tx_ring->buffer_info[tx_ring->next_to_clean];
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   256
	pr_info(" %5d %5X %5X %016llX %04X %3X %016llX\n",
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   257
		0, tx_ring->next_to_use, tx_ring->next_to_clean,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   258
		(unsigned long long)buffer_info->dma,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   259
		buffer_info->length,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   260
		buffer_info->next_to_watch,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   261
		(unsigned long long)buffer_info->time_stamp);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   262
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   263
	/* Print Tx Ring */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   264
	if (!netif_msg_tx_done(adapter))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   265
		goto rx_ring_summary;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   266
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   267
	dev_info(&adapter->pdev->dev, "Tx Ring Dump\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   268
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   269
	/* Transmit Descriptor Formats - DEXT[29] is 0 (Legacy) or 1 (Extended)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   270
	 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   271
	 * Legacy Transmit Descriptor
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   272
	 *   +--------------------------------------------------------------+
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   273
	 * 0 |         Buffer Address [63:0] (Reserved on Write Back)       |
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   274
	 *   +--------------------------------------------------------------+
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   275
	 * 8 | Special  |    CSS     | Status |  CMD    |  CSO   |  Length  |
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   276
	 *   +--------------------------------------------------------------+
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   277
	 *   63       48 47        36 35    32 31     24 23    16 15        0
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   278
	 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   279
	 * Extended Context Descriptor (DTYP=0x0) for TSO or checksum offload
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   280
	 *   63      48 47    40 39       32 31             16 15    8 7      0
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   281
	 *   +----------------------------------------------------------------+
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   282
	 * 0 |  TUCSE  | TUCS0  |   TUCSS   |     IPCSE       | IPCS0 | IPCSS |
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   283
	 *   +----------------------------------------------------------------+
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   284
	 * 8 |   MSS   | HDRLEN | RSV | STA | TUCMD | DTYP |      PAYLEN      |
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   285
	 *   +----------------------------------------------------------------+
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   286
	 *   63      48 47    40 39 36 35 32 31   24 23  20 19                0
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   287
	 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   288
	 * Extended Data Descriptor (DTYP=0x1)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   289
	 *   +----------------------------------------------------------------+
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   290
	 * 0 |                     Buffer Address [63:0]                      |
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   291
	 *   +----------------------------------------------------------------+
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   292
	 * 8 | VLAN tag |  POPTS  | Rsvd | Status | Command | DTYP |  DTALEN  |
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   293
	 *   +----------------------------------------------------------------+
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   294
	 *   63       48 47     40 39  36 35    32 31     24 23  20 19        0
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   295
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   296
	pr_info("Tl[desc]     [address 63:0  ] [SpeCssSCmCsLen] [bi->dma       ] leng  ntw timestamp        bi->skb <-- Legacy format\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   297
	pr_info("Tc[desc]     [Ce CoCsIpceCoS] [MssHlRSCm0Plen] [bi->dma       ] leng  ntw timestamp        bi->skb <-- Ext Context format\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   298
	pr_info("Td[desc]     [address 63:0  ] [VlaPoRSCm1Dlen] [bi->dma       ] leng  ntw timestamp        bi->skb <-- Ext Data format\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   299
	for (i = 0; tx_ring->desc && (i < tx_ring->count); i++) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   300
		const char *next_desc;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   301
		tx_desc = E1000_TX_DESC(*tx_ring, i);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   302
		buffer_info = &tx_ring->buffer_info[i];
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   303
		u0 = (struct my_u0 *)tx_desc;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   304
		if (i == tx_ring->next_to_use && i == tx_ring->next_to_clean)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   305
			next_desc = " NTC/U";
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   306
		else if (i == tx_ring->next_to_use)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   307
			next_desc = " NTU";
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   308
		else if (i == tx_ring->next_to_clean)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   309
			next_desc = " NTC";
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   310
		else
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   311
			next_desc = "";
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   312
		pr_info("T%c[0x%03X]    %016llX %016llX %016llX %04X  %3X %016llX %p%s\n",
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   313
			(!(le64_to_cpu(u0->b) & (1 << 29)) ? 'l' :
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   314
			 ((le64_to_cpu(u0->b) & (1 << 20)) ? 'd' : 'c')),
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   315
			i,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   316
			(unsigned long long)le64_to_cpu(u0->a),
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   317
			(unsigned long long)le64_to_cpu(u0->b),
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   318
			(unsigned long long)buffer_info->dma,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   319
			buffer_info->length, buffer_info->next_to_watch,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   320
			(unsigned long long)buffer_info->time_stamp,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   321
			buffer_info->skb, next_desc);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   322
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   323
		if (netif_msg_pktdata(adapter) && buffer_info->skb)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   324
			print_hex_dump(KERN_INFO, "", DUMP_PREFIX_ADDRESS,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   325
				       16, 1, buffer_info->skb->data,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   326
				       buffer_info->skb->len, true);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   327
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   328
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   329
	/* Print Rx Ring Summary */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   330
rx_ring_summary:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   331
	dev_info(&adapter->pdev->dev, "Rx Ring Summary\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   332
	pr_info("Queue [NTU] [NTC]\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   333
	pr_info(" %5d %5X %5X\n",
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   334
		0, rx_ring->next_to_use, rx_ring->next_to_clean);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   335
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   336
	/* Print Rx Ring */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   337
	if (!netif_msg_rx_status(adapter))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   338
		return;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   339
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   340
	dev_info(&adapter->pdev->dev, "Rx Ring Dump\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   341
	switch (adapter->rx_ps_pages) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   342
	case 1:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   343
	case 2:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   344
	case 3:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   345
		/* [Extended] Packet Split Receive Descriptor Format
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   346
		 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   347
		 *    +-----------------------------------------------------+
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   348
		 *  0 |                Buffer Address 0 [63:0]              |
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   349
		 *    +-----------------------------------------------------+
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   350
		 *  8 |                Buffer Address 1 [63:0]              |
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   351
		 *    +-----------------------------------------------------+
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   352
		 * 16 |                Buffer Address 2 [63:0]              |
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   353
		 *    +-----------------------------------------------------+
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   354
		 * 24 |                Buffer Address 3 [63:0]              |
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   355
		 *    +-----------------------------------------------------+
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   356
		 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   357
		pr_info("R  [desc]      [buffer 0 63:0 ] [buffer 1 63:0 ] [buffer 2 63:0 ] [buffer 3 63:0 ] [bi->dma       ] [bi->skb] <-- Ext Pkt Split format\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   358
		/* [Extended] Receive Descriptor (Write-Back) Format
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   359
		 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   360
		 *   63       48 47    32 31     13 12    8 7    4 3        0
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   361
		 *   +------------------------------------------------------+
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   362
		 * 0 | Packet   | IP     |  Rsvd   | MRQ   | Rsvd | MRQ RSS |
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   363
		 *   | Checksum | Ident  |         | Queue |      |  Type   |
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   364
		 *   +------------------------------------------------------+
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   365
		 * 8 | VLAN Tag | Length | Extended Error | Extended Status |
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   366
		 *   +------------------------------------------------------+
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   367
		 *   63       48 47    32 31            20 19               0
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   368
		 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   369
		pr_info("RWB[desc]      [ck ipid mrqhsh] [vl   l0 ee  es] [ l3  l2  l1 hs] [reserved      ] ---------------- [bi->skb] <-- Ext Rx Write-Back format\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   370
		for (i = 0; i < rx_ring->count; i++) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   371
			const char *next_desc;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   372
			buffer_info = &rx_ring->buffer_info[i];
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   373
			rx_desc_ps = E1000_RX_DESC_PS(*rx_ring, i);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   374
			u1 = (struct my_u1 *)rx_desc_ps;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   375
			staterr =
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   376
			    le32_to_cpu(rx_desc_ps->wb.middle.status_error);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   377
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   378
			if (i == rx_ring->next_to_use)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   379
				next_desc = " NTU";
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   380
			else if (i == rx_ring->next_to_clean)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   381
				next_desc = " NTC";
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   382
			else
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   383
				next_desc = "";
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   384
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   385
			if (staterr & E1000_RXD_STAT_DD) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   386
				/* Descriptor Done */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   387
				pr_info("%s[0x%03X]     %016llX %016llX %016llX %016llX ---------------- %p%s\n",
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   388
					"RWB", i,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   389
					(unsigned long long)le64_to_cpu(u1->a),
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   390
					(unsigned long long)le64_to_cpu(u1->b),
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   391
					(unsigned long long)le64_to_cpu(u1->c),
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   392
					(unsigned long long)le64_to_cpu(u1->d),
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   393
					buffer_info->skb, next_desc);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   394
			} else {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   395
				pr_info("%s[0x%03X]     %016llX %016llX %016llX %016llX %016llX %p%s\n",
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   396
					"R  ", i,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   397
					(unsigned long long)le64_to_cpu(u1->a),
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   398
					(unsigned long long)le64_to_cpu(u1->b),
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   399
					(unsigned long long)le64_to_cpu(u1->c),
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   400
					(unsigned long long)le64_to_cpu(u1->d),
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   401
					(unsigned long long)buffer_info->dma,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   402
					buffer_info->skb, next_desc);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   403
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   404
				if (netif_msg_pktdata(adapter))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   405
					e1000e_dump_ps_pages(adapter,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   406
							     buffer_info);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   407
			}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   408
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   409
		break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   410
	default:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   411
	case 0:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   412
		/* Extended Receive Descriptor (Read) Format
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   413
		 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   414
		 *   +-----------------------------------------------------+
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   415
		 * 0 |                Buffer Address [63:0]                |
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   416
		 *   +-----------------------------------------------------+
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   417
		 * 8 |                      Reserved                       |
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   418
		 *   +-----------------------------------------------------+
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   419
		 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   420
		pr_info("R  [desc]      [buf addr 63:0 ] [reserved 63:0 ] [bi->dma       ] [bi->skb] <-- Ext (Read) format\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   421
		/* Extended Receive Descriptor (Write-Back) Format
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   422
		 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   423
		 *   63       48 47    32 31    24 23            4 3        0
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   424
		 *   +------------------------------------------------------+
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   425
		 *   |     RSS Hash      |        |               |         |
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   426
		 * 0 +-------------------+  Rsvd  |   Reserved    | MRQ RSS |
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   427
		 *   | Packet   | IP     |        |               |  Type   |
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   428
		 *   | Checksum | Ident  |        |               |         |
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   429
		 *   +------------------------------------------------------+
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   430
		 * 8 | VLAN Tag | Length | Extended Error | Extended Status |
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   431
		 *   +------------------------------------------------------+
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   432
		 *   63       48 47    32 31            20 19               0
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   433
		 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   434
		pr_info("RWB[desc]      [cs ipid    mrq] [vt   ln xe  xs] [bi->skb] <-- Ext (Write-Back) format\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   435
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   436
		for (i = 0; i < rx_ring->count; i++) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   437
			const char *next_desc;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   438
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   439
			buffer_info = &rx_ring->buffer_info[i];
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   440
			rx_desc = E1000_RX_DESC_EXT(*rx_ring, i);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   441
			u1 = (struct my_u1 *)rx_desc;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   442
			staterr = le32_to_cpu(rx_desc->wb.upper.status_error);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   443
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   444
			if (i == rx_ring->next_to_use)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   445
				next_desc = " NTU";
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   446
			else if (i == rx_ring->next_to_clean)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   447
				next_desc = " NTC";
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   448
			else
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   449
				next_desc = "";
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   450
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   451
			if (staterr & E1000_RXD_STAT_DD) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   452
				/* Descriptor Done */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   453
				pr_info("%s[0x%03X]     %016llX %016llX ---------------- %p%s\n",
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   454
					"RWB", i,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   455
					(unsigned long long)le64_to_cpu(u1->a),
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   456
					(unsigned long long)le64_to_cpu(u1->b),
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   457
					buffer_info->skb, next_desc);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   458
			} else {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   459
				pr_info("%s[0x%03X]     %016llX %016llX %016llX %p%s\n",
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   460
					"R  ", i,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   461
					(unsigned long long)le64_to_cpu(u1->a),
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   462
					(unsigned long long)le64_to_cpu(u1->b),
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   463
					(unsigned long long)buffer_info->dma,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   464
					buffer_info->skb, next_desc);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   465
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   466
				if (netif_msg_pktdata(adapter) &&
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   467
				    buffer_info->skb)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   468
					print_hex_dump(KERN_INFO, "",
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   469
						       DUMP_PREFIX_ADDRESS, 16,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   470
						       1,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   471
						       buffer_info->skb->data,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   472
						       adapter->rx_buffer_len,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   473
						       true);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   474
			}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   475
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   476
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   477
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   478
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   479
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   480
 * e1000_desc_unused - calculate if we have unused descriptors
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   481
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   482
static int e1000_desc_unused(struct e1000_ring *ring)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   483
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   484
	if (ring->next_to_clean > ring->next_to_use)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   485
		return ring->next_to_clean - ring->next_to_use - 1;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   486
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   487
	return ring->count + ring->next_to_clean - ring->next_to_use - 1;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   488
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   489
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   490
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   491
 * e1000_receive_skb - helper function to handle Rx indications
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   492
 * @adapter: board private structure
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   493
 * @status: descriptor status field as written by hardware
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   494
 * @vlan: descriptor vlan field as written by hardware (no le/be conversion)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   495
 * @skb: pointer to sk_buff to be indicated to stack
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   496
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   497
static void e1000_receive_skb(struct e1000_adapter *adapter,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   498
			      struct net_device *netdev, struct sk_buff *skb,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   499
			      u8 status, __le16 vlan)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   500
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   501
	u16 tag = le16_to_cpu(vlan);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   502
	skb->protocol = eth_type_trans(skb, netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   503
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   504
	if (status & E1000_RXD_STAT_VP)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   505
		__vlan_hwaccel_put_tag(skb, tag);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   506
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   507
	napi_gro_receive(&adapter->napi, skb);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   508
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   509
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   510
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   511
 * e1000_rx_checksum - Receive Checksum Offload
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   512
 * @adapter: board private structure
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   513
 * @status_err: receive descriptor status and error fields
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   514
 * @csum: receive descriptor csum field
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   515
 * @sk_buff: socket buffer with received data
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   516
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   517
static void e1000_rx_checksum(struct e1000_adapter *adapter, u32 status_err,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   518
			      struct sk_buff *skb)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   519
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   520
	u16 status = (u16)status_err;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   521
	u8 errors = (u8)(status_err >> 24);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   522
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   523
	skb_checksum_none_assert(skb);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   524
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   525
	/* Rx checksum disabled */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   526
	if (!(adapter->netdev->features & NETIF_F_RXCSUM))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   527
		return;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   528
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   529
	/* Ignore Checksum bit is set */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   530
	if (status & E1000_RXD_STAT_IXSM)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   531
		return;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   532
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   533
	/* TCP/UDP checksum error bit or IP checksum error bit is set */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   534
	if (errors & (E1000_RXD_ERR_TCPE | E1000_RXD_ERR_IPE)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   535
		/* let the stack verify checksum errors */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   536
		adapter->hw_csum_err++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   537
		return;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   538
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   539
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   540
	/* TCP/UDP Checksum has not been calculated */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   541
	if (!(status & (E1000_RXD_STAT_TCPCS | E1000_RXD_STAT_UDPCS)))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   542
		return;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   543
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   544
	/* It must be a TCP or UDP packet with a valid checksum */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   545
	skb->ip_summed = CHECKSUM_UNNECESSARY;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   546
	adapter->hw_csum_good++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   547
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   548
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   549
static void e1000e_update_rdt_wa(struct e1000_ring *rx_ring, unsigned int i)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   550
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   551
	struct e1000_adapter *adapter = rx_ring->adapter;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   552
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   553
	s32 ret_val = __ew32_prepare(hw);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   554
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   555
	writel(i, rx_ring->tail);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   556
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   557
	if (unlikely(!ret_val && (i != readl(rx_ring->tail)))) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   558
		u32 rctl = er32(RCTL);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   559
		ew32(RCTL, rctl & ~E1000_RCTL_EN);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   560
		e_err("ME firmware caused invalid RDT - resetting\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   561
		schedule_work(&adapter->reset_task);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   562
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   563
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   564
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   565
static void e1000e_update_tdt_wa(struct e1000_ring *tx_ring, unsigned int i)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   566
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   567
	struct e1000_adapter *adapter = tx_ring->adapter;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   568
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   569
	s32 ret_val = __ew32_prepare(hw);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   570
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   571
	writel(i, tx_ring->tail);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   572
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   573
	if (unlikely(!ret_val && (i != readl(tx_ring->tail)))) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   574
		u32 tctl = er32(TCTL);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   575
		ew32(TCTL, tctl & ~E1000_TCTL_EN);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   576
		e_err("ME firmware caused invalid TDT - resetting\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   577
		schedule_work(&adapter->reset_task);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   578
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   579
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   580
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   581
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   582
 * e1000_alloc_rx_buffers - Replace used receive buffers
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   583
 * @rx_ring: Rx descriptor ring
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   584
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   585
static void e1000_alloc_rx_buffers(struct e1000_ring *rx_ring,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   586
				   int cleaned_count, gfp_t gfp)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   587
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   588
	struct e1000_adapter *adapter = rx_ring->adapter;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   589
	struct net_device *netdev = adapter->netdev;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   590
	struct pci_dev *pdev = adapter->pdev;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   591
	union e1000_rx_desc_extended *rx_desc;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   592
	struct e1000_buffer *buffer_info;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   593
	struct sk_buff *skb;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   594
	unsigned int i;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   595
	unsigned int bufsz = adapter->rx_buffer_len;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   596
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   597
	i = rx_ring->next_to_use;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   598
	buffer_info = &rx_ring->buffer_info[i];
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   599
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   600
	while (cleaned_count--) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   601
		skb = buffer_info->skb;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   602
		if (skb) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   603
			skb_trim(skb, 0);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   604
			goto map_skb;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   605
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   606
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   607
		skb = __netdev_alloc_skb_ip_align(netdev, bufsz, gfp);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   608
		if (!skb) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   609
			/* Better luck next round */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   610
			adapter->alloc_rx_buff_failed++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   611
			break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   612
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   613
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   614
		buffer_info->skb = skb;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   615
map_skb:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   616
		buffer_info->dma = dma_map_single(&pdev->dev, skb->data,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   617
						  adapter->rx_buffer_len,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   618
						  DMA_FROM_DEVICE);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   619
		if (dma_mapping_error(&pdev->dev, buffer_info->dma)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   620
			dev_err(&pdev->dev, "Rx DMA map failed\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   621
			adapter->rx_dma_failed++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   622
			break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   623
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   624
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   625
		rx_desc = E1000_RX_DESC_EXT(*rx_ring, i);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   626
		rx_desc->read.buffer_addr = cpu_to_le64(buffer_info->dma);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   627
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   628
		if (unlikely(!(i & (E1000_RX_BUFFER_WRITE - 1)))) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   629
			/* Force memory writes to complete before letting h/w
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   630
			 * know there are new descriptors to fetch.  (Only
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   631
			 * applicable for weak-ordered memory model archs,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   632
			 * such as IA-64).
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   633
			 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   634
			wmb();
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   635
			if (adapter->flags2 & FLAG2_PCIM2PCI_ARBITER_WA)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   636
				e1000e_update_rdt_wa(rx_ring, i);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   637
			else
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   638
				writel(i, rx_ring->tail);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   639
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   640
		i++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   641
		if (i == rx_ring->count)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   642
			i = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   643
		buffer_info = &rx_ring->buffer_info[i];
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   644
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   645
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   646
	rx_ring->next_to_use = i;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   647
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   648
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   649
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   650
 * e1000_alloc_rx_buffers_ps - Replace used receive buffers; packet split
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   651
 * @rx_ring: Rx descriptor ring
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   652
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   653
static void e1000_alloc_rx_buffers_ps(struct e1000_ring *rx_ring,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   654
				      int cleaned_count, gfp_t gfp)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   655
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   656
	struct e1000_adapter *adapter = rx_ring->adapter;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   657
	struct net_device *netdev = adapter->netdev;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   658
	struct pci_dev *pdev = adapter->pdev;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   659
	union e1000_rx_desc_packet_split *rx_desc;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   660
	struct e1000_buffer *buffer_info;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   661
	struct e1000_ps_page *ps_page;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   662
	struct sk_buff *skb;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   663
	unsigned int i, j;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   664
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   665
	i = rx_ring->next_to_use;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   666
	buffer_info = &rx_ring->buffer_info[i];
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   667
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   668
	while (cleaned_count--) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   669
		rx_desc = E1000_RX_DESC_PS(*rx_ring, i);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   670
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   671
		for (j = 0; j < PS_PAGE_BUFFERS; j++) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   672
			ps_page = &buffer_info->ps_pages[j];
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   673
			if (j >= adapter->rx_ps_pages) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   674
				/* all unused desc entries get hw null ptr */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   675
				rx_desc->read.buffer_addr[j + 1] =
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   676
				    ~cpu_to_le64(0);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   677
				continue;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   678
			}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   679
			if (!ps_page->page) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   680
				ps_page->page = alloc_page(gfp);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   681
				if (!ps_page->page) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   682
					adapter->alloc_rx_buff_failed++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   683
					goto no_buffers;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   684
				}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   685
				ps_page->dma = dma_map_page(&pdev->dev,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   686
							    ps_page->page,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   687
							    0, PAGE_SIZE,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   688
							    DMA_FROM_DEVICE);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   689
				if (dma_mapping_error(&pdev->dev,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   690
						      ps_page->dma)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   691
					dev_err(&adapter->pdev->dev,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   692
						"Rx DMA page map failed\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   693
					adapter->rx_dma_failed++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   694
					goto no_buffers;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   695
				}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   696
			}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   697
			/* Refresh the desc even if buffer_addrs
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   698
			 * didn't change because each write-back
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   699
			 * erases this info.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   700
			 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   701
			rx_desc->read.buffer_addr[j + 1] =
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   702
			    cpu_to_le64(ps_page->dma);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   703
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   704
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   705
		skb = __netdev_alloc_skb_ip_align(netdev,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   706
						  adapter->rx_ps_bsize0,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   707
						  gfp);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   708
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   709
		if (!skb) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   710
			adapter->alloc_rx_buff_failed++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   711
			break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   712
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   713
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   714
		buffer_info->skb = skb;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   715
		buffer_info->dma = dma_map_single(&pdev->dev, skb->data,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   716
						  adapter->rx_ps_bsize0,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   717
						  DMA_FROM_DEVICE);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   718
		if (dma_mapping_error(&pdev->dev, buffer_info->dma)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   719
			dev_err(&pdev->dev, "Rx DMA map failed\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   720
			adapter->rx_dma_failed++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   721
			/* cleanup skb */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   722
			dev_kfree_skb_any(skb);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   723
			buffer_info->skb = NULL;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   724
			break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   725
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   726
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   727
		rx_desc->read.buffer_addr[0] = cpu_to_le64(buffer_info->dma);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   728
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   729
		if (unlikely(!(i & (E1000_RX_BUFFER_WRITE - 1)))) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   730
			/* Force memory writes to complete before letting h/w
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   731
			 * know there are new descriptors to fetch.  (Only
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   732
			 * applicable for weak-ordered memory model archs,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   733
			 * such as IA-64).
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   734
			 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   735
			wmb();
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   736
			if (adapter->flags2 & FLAG2_PCIM2PCI_ARBITER_WA)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   737
				e1000e_update_rdt_wa(rx_ring, i << 1);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   738
			else
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   739
				writel(i << 1, rx_ring->tail);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   740
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   741
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   742
		i++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   743
		if (i == rx_ring->count)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   744
			i = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   745
		buffer_info = &rx_ring->buffer_info[i];
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   746
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   747
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   748
no_buffers:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   749
	rx_ring->next_to_use = i;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   750
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   751
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   752
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   753
 * e1000_alloc_jumbo_rx_buffers - Replace used jumbo receive buffers
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   754
 * @rx_ring: Rx descriptor ring
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   755
 * @cleaned_count: number of buffers to allocate this pass
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   756
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   757
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   758
static void e1000_alloc_jumbo_rx_buffers(struct e1000_ring *rx_ring,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   759
					 int cleaned_count, gfp_t gfp)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   760
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   761
	struct e1000_adapter *adapter = rx_ring->adapter;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   762
	struct net_device *netdev = adapter->netdev;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   763
	struct pci_dev *pdev = adapter->pdev;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   764
	union e1000_rx_desc_extended *rx_desc;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   765
	struct e1000_buffer *buffer_info;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   766
	struct sk_buff *skb;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   767
	unsigned int i;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   768
	unsigned int bufsz = 256 - 16 /* for skb_reserve */;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   769
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   770
	i = rx_ring->next_to_use;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   771
	buffer_info = &rx_ring->buffer_info[i];
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   772
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   773
	while (cleaned_count--) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   774
		skb = buffer_info->skb;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   775
		if (skb) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   776
			skb_trim(skb, 0);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   777
			goto check_page;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   778
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   779
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   780
		skb = __netdev_alloc_skb_ip_align(netdev, bufsz, gfp);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   781
		if (unlikely(!skb)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   782
			/* Better luck next round */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   783
			adapter->alloc_rx_buff_failed++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   784
			break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   785
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   786
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   787
		buffer_info->skb = skb;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   788
check_page:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   789
		/* allocate a new page if necessary */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   790
		if (!buffer_info->page) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   791
			buffer_info->page = alloc_page(gfp);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   792
			if (unlikely(!buffer_info->page)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   793
				adapter->alloc_rx_buff_failed++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   794
				break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   795
			}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   796
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   797
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   798
		if (!buffer_info->dma)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   799
			buffer_info->dma = dma_map_page(&pdev->dev,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   800
			                                buffer_info->page, 0,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   801
			                                PAGE_SIZE,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   802
							DMA_FROM_DEVICE);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   803
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   804
		rx_desc = E1000_RX_DESC_EXT(*rx_ring, i);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   805
		rx_desc->read.buffer_addr = cpu_to_le64(buffer_info->dma);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   806
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   807
		if (unlikely(++i == rx_ring->count))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   808
			i = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   809
		buffer_info = &rx_ring->buffer_info[i];
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   810
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   811
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   812
	if (likely(rx_ring->next_to_use != i)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   813
		rx_ring->next_to_use = i;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   814
		if (unlikely(i-- == 0))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   815
			i = (rx_ring->count - 1);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   816
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   817
		/* Force memory writes to complete before letting h/w
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   818
		 * know there are new descriptors to fetch.  (Only
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   819
		 * applicable for weak-ordered memory model archs,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   820
		 * such as IA-64).
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   821
		 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   822
		wmb();
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   823
		if (adapter->flags2 & FLAG2_PCIM2PCI_ARBITER_WA)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   824
			e1000e_update_rdt_wa(rx_ring, i);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   825
		else
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   826
			writel(i, rx_ring->tail);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   827
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   828
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   829
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   830
static inline void e1000_rx_hash(struct net_device *netdev, __le32 rss,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   831
				 struct sk_buff *skb)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   832
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   833
	if (netdev->features & NETIF_F_RXHASH)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   834
		skb->rxhash = le32_to_cpu(rss);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   835
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   836
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   837
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   838
 * e1000_clean_rx_irq - Send received data up the network stack
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   839
 * @rx_ring: Rx descriptor ring
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   840
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   841
 * the return value indicates whether actual cleaning was done, there
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   842
 * is no guarantee that everything was cleaned
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   843
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   844
static bool e1000_clean_rx_irq(struct e1000_ring *rx_ring, int *work_done,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   845
			       int work_to_do)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   846
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   847
	struct e1000_adapter *adapter = rx_ring->adapter;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   848
	struct net_device *netdev = adapter->netdev;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   849
	struct pci_dev *pdev = adapter->pdev;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   850
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   851
	union e1000_rx_desc_extended *rx_desc, *next_rxd;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   852
	struct e1000_buffer *buffer_info, *next_buffer;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   853
	u32 length, staterr;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   854
	unsigned int i;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   855
	int cleaned_count = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   856
	bool cleaned = false;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   857
	unsigned int total_rx_bytes = 0, total_rx_packets = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   858
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   859
	i = rx_ring->next_to_clean;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   860
	rx_desc = E1000_RX_DESC_EXT(*rx_ring, i);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   861
	staterr = le32_to_cpu(rx_desc->wb.upper.status_error);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   862
	buffer_info = &rx_ring->buffer_info[i];
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   863
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   864
	while (staterr & E1000_RXD_STAT_DD) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   865
		struct sk_buff *skb;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   866
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   867
		if (*work_done >= work_to_do)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   868
			break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   869
		(*work_done)++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   870
		rmb();	/* read descriptor and rx_buffer_info after status DD */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   871
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   872
		skb = buffer_info->skb;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   873
		buffer_info->skb = NULL;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   874
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   875
		prefetch(skb->data - NET_IP_ALIGN);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   876
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   877
		i++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   878
		if (i == rx_ring->count)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   879
			i = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   880
		next_rxd = E1000_RX_DESC_EXT(*rx_ring, i);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   881
		prefetch(next_rxd);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   882
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   883
		next_buffer = &rx_ring->buffer_info[i];
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   884
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   885
		cleaned = true;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   886
		cleaned_count++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   887
		dma_unmap_single(&pdev->dev,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   888
				 buffer_info->dma,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   889
				 adapter->rx_buffer_len,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   890
				 DMA_FROM_DEVICE);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   891
		buffer_info->dma = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   892
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   893
		length = le16_to_cpu(rx_desc->wb.upper.length);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   894
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   895
		/* !EOP means multiple descriptors were used to store a single
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   896
		 * packet, if that's the case we need to toss it.  In fact, we
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   897
		 * need to toss every packet with the EOP bit clear and the
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   898
		 * next frame that _does_ have the EOP bit set, as it is by
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   899
		 * definition only a frame fragment
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   900
		 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   901
		if (unlikely(!(staterr & E1000_RXD_STAT_EOP)))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   902
			adapter->flags2 |= FLAG2_IS_DISCARDING;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   903
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   904
		if (adapter->flags2 & FLAG2_IS_DISCARDING) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   905
			/* All receives must fit into a single buffer */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   906
			e_dbg("Receive packet consumed multiple buffers\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   907
			/* recycle */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   908
			buffer_info->skb = skb;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   909
			if (staterr & E1000_RXD_STAT_EOP)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   910
				adapter->flags2 &= ~FLAG2_IS_DISCARDING;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   911
			goto next_desc;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   912
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   913
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   914
		if (unlikely((staterr & E1000_RXDEXT_ERR_FRAME_ERR_MASK) &&
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   915
			     !(netdev->features & NETIF_F_RXALL))) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   916
			/* recycle */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   917
			buffer_info->skb = skb;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   918
			goto next_desc;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   919
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   920
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   921
		/* adjust length to remove Ethernet CRC */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   922
		if (!(adapter->flags2 & FLAG2_CRC_STRIPPING)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   923
			/* If configured to store CRC, don't subtract FCS,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   924
			 * but keep the FCS bytes out of the total_rx_bytes
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   925
			 * counter
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   926
			 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   927
			if (netdev->features & NETIF_F_RXFCS)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   928
				total_rx_bytes -= 4;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   929
			else
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   930
				length -= 4;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   931
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   932
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   933
		total_rx_bytes += length;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   934
		total_rx_packets++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   935
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   936
		/* code added for copybreak, this should improve
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   937
		 * performance for small packets with large amounts
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   938
		 * of reassembly being done in the stack
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   939
		 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   940
		if (length < copybreak) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   941
			struct sk_buff *new_skb =
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   942
			    netdev_alloc_skb_ip_align(netdev, length);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   943
			if (new_skb) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   944
				skb_copy_to_linear_data_offset(new_skb,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   945
							       -NET_IP_ALIGN,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   946
							       (skb->data -
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   947
								NET_IP_ALIGN),
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   948
							       (length +
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   949
								NET_IP_ALIGN));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   950
				/* save the skb in buffer_info as good */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   951
				buffer_info->skb = skb;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   952
				skb = new_skb;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   953
			}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   954
			/* else just continue with the old one */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   955
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   956
		/* end copybreak code */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   957
		skb_put(skb, length);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   958
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   959
		/* Receive Checksum Offload */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   960
		e1000_rx_checksum(adapter, staterr, skb);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   961
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   962
		e1000_rx_hash(netdev, rx_desc->wb.lower.hi_dword.rss, skb);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   963
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   964
		e1000_receive_skb(adapter, netdev, skb, staterr,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   965
				  rx_desc->wb.upper.vlan);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   966
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   967
next_desc:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   968
		rx_desc->wb.upper.status_error &= cpu_to_le32(~0xFF);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   969
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   970
		/* return some buffers to hardware, one at a time is too slow */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   971
		if (cleaned_count >= E1000_RX_BUFFER_WRITE) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   972
			adapter->alloc_rx_buf(rx_ring, cleaned_count,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   973
					      GFP_ATOMIC);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   974
			cleaned_count = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   975
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   976
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   977
		/* use prefetched values */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   978
		rx_desc = next_rxd;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   979
		buffer_info = next_buffer;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   980
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   981
		staterr = le32_to_cpu(rx_desc->wb.upper.status_error);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   982
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   983
	rx_ring->next_to_clean = i;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   984
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   985
	cleaned_count = e1000_desc_unused(rx_ring);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   986
	if (cleaned_count)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   987
		adapter->alloc_rx_buf(rx_ring, cleaned_count, GFP_ATOMIC);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   988
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   989
	adapter->total_rx_bytes += total_rx_bytes;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   990
	adapter->total_rx_packets += total_rx_packets;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   991
	return cleaned;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   992
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   993
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   994
static void e1000_put_txbuf(struct e1000_ring *tx_ring,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   995
			    struct e1000_buffer *buffer_info)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   996
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   997
	struct e1000_adapter *adapter = tx_ring->adapter;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   998
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   999
	if (buffer_info->dma) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1000
		if (buffer_info->mapped_as_page)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1001
			dma_unmap_page(&adapter->pdev->dev, buffer_info->dma,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1002
				       buffer_info->length, DMA_TO_DEVICE);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1003
		else
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1004
			dma_unmap_single(&adapter->pdev->dev, buffer_info->dma,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1005
					 buffer_info->length, DMA_TO_DEVICE);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1006
		buffer_info->dma = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1007
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1008
	if (buffer_info->skb) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1009
		dev_kfree_skb_any(buffer_info->skb);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1010
		buffer_info->skb = NULL;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1011
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1012
	buffer_info->time_stamp = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1013
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1014
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1015
static void e1000_print_hw_hang(struct work_struct *work)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1016
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1017
	struct e1000_adapter *adapter = container_of(work,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1018
	                                             struct e1000_adapter,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1019
	                                             print_hang_task);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1020
	struct net_device *netdev = adapter->netdev;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1021
	struct e1000_ring *tx_ring = adapter->tx_ring;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1022
	unsigned int i = tx_ring->next_to_clean;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1023
	unsigned int eop = tx_ring->buffer_info[i].next_to_watch;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1024
	struct e1000_tx_desc *eop_desc = E1000_TX_DESC(*tx_ring, eop);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1025
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1026
	u16 phy_status, phy_1000t_status, phy_ext_status;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1027
	u16 pci_status;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1028
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1029
	if (test_bit(__E1000_DOWN, &adapter->state))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1030
		return;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1031
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1032
	if (!adapter->tx_hang_recheck &&
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1033
	    (adapter->flags2 & FLAG2_DMA_BURST)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1034
		/* May be block on write-back, flush and detect again
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1035
		 * flush pending descriptor writebacks to memory
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1036
		 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1037
		ew32(TIDV, adapter->tx_int_delay | E1000_TIDV_FPD);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1038
		/* execute the writes immediately */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1039
		e1e_flush();
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1040
		/* Due to rare timing issues, write to TIDV again to ensure
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1041
		 * the write is successful
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1042
		 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1043
		ew32(TIDV, adapter->tx_int_delay | E1000_TIDV_FPD);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1044
		/* execute the writes immediately */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1045
		e1e_flush();
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1046
		adapter->tx_hang_recheck = true;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1047
		return;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1048
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1049
	/* Real hang detected */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1050
	adapter->tx_hang_recheck = false;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1051
	netif_stop_queue(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1052
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1053
	e1e_rphy(hw, PHY_STATUS, &phy_status);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1054
	e1e_rphy(hw, PHY_1000T_STATUS, &phy_1000t_status);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1055
	e1e_rphy(hw, PHY_EXT_STATUS, &phy_ext_status);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1056
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1057
	pci_read_config_word(adapter->pdev, PCI_STATUS, &pci_status);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1058
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1059
	/* detected Hardware unit hang */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1060
	e_err("Detected Hardware Unit Hang:\n"
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1061
	      "  TDH                  <%x>\n"
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1062
	      "  TDT                  <%x>\n"
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1063
	      "  next_to_use          <%x>\n"
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1064
	      "  next_to_clean        <%x>\n"
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1065
	      "buffer_info[next_to_clean]:\n"
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1066
	      "  time_stamp           <%lx>\n"
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1067
	      "  next_to_watch        <%x>\n"
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1068
	      "  jiffies              <%lx>\n"
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1069
	      "  next_to_watch.status <%x>\n"
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1070
	      "MAC Status             <%x>\n"
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1071
	      "PHY Status             <%x>\n"
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1072
	      "PHY 1000BASE-T Status  <%x>\n"
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1073
	      "PHY Extended Status    <%x>\n"
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1074
	      "PCI Status             <%x>\n",
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1075
	      readl(tx_ring->head),
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1076
	      readl(tx_ring->tail),
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1077
	      tx_ring->next_to_use,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1078
	      tx_ring->next_to_clean,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1079
	      tx_ring->buffer_info[eop].time_stamp,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1080
	      eop,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1081
	      jiffies,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1082
	      eop_desc->upper.fields.status,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1083
	      er32(STATUS),
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1084
	      phy_status,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1085
	      phy_1000t_status,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1086
	      phy_ext_status,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1087
	      pci_status);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1088
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1089
	/* Suggest workaround for known h/w issue */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1090
	if ((hw->mac.type == e1000_pchlan) && (er32(CTRL) & E1000_CTRL_TFCE))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1091
		e_err("Try turning off Tx pause (flow control) via ethtool\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1092
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1093
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1094
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1095
 * e1000_clean_tx_irq - Reclaim resources after transmit completes
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1096
 * @tx_ring: Tx descriptor ring
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1097
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1098
 * the return value indicates whether actual cleaning was done, there
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1099
 * is no guarantee that everything was cleaned
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1100
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1101
static bool e1000_clean_tx_irq(struct e1000_ring *tx_ring)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1102
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1103
	struct e1000_adapter *adapter = tx_ring->adapter;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1104
	struct net_device *netdev = adapter->netdev;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1105
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1106
	struct e1000_tx_desc *tx_desc, *eop_desc;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1107
	struct e1000_buffer *buffer_info;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1108
	unsigned int i, eop;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1109
	unsigned int count = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1110
	unsigned int total_tx_bytes = 0, total_tx_packets = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1111
	unsigned int bytes_compl = 0, pkts_compl = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1112
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1113
	i = tx_ring->next_to_clean;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1114
	eop = tx_ring->buffer_info[i].next_to_watch;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1115
	eop_desc = E1000_TX_DESC(*tx_ring, eop);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1116
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1117
	while ((eop_desc->upper.data & cpu_to_le32(E1000_TXD_STAT_DD)) &&
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1118
	       (count < tx_ring->count)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1119
		bool cleaned = false;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1120
		rmb(); /* read buffer_info after eop_desc */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1121
		for (; !cleaned; count++) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1122
			tx_desc = E1000_TX_DESC(*tx_ring, i);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1123
			buffer_info = &tx_ring->buffer_info[i];
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1124
			cleaned = (i == eop);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1125
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1126
			if (cleaned) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1127
				total_tx_packets += buffer_info->segs;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1128
				total_tx_bytes += buffer_info->bytecount;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1129
				if (buffer_info->skb) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1130
					bytes_compl += buffer_info->skb->len;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1131
					pkts_compl++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1132
				}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1133
			}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1134
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1135
			e1000_put_txbuf(tx_ring, buffer_info);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1136
			tx_desc->upper.data = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1137
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1138
			i++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1139
			if (i == tx_ring->count)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1140
				i = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1141
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1142
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1143
		if (i == tx_ring->next_to_use)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1144
			break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1145
		eop = tx_ring->buffer_info[i].next_to_watch;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1146
		eop_desc = E1000_TX_DESC(*tx_ring, eop);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1147
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1148
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1149
	tx_ring->next_to_clean = i;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1150
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1151
	netdev_completed_queue(netdev, pkts_compl, bytes_compl);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1152
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1153
#define TX_WAKE_THRESHOLD 32
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1154
	if (count && netif_carrier_ok(netdev) &&
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1155
	    e1000_desc_unused(tx_ring) >= TX_WAKE_THRESHOLD) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1156
		/* Make sure that anybody stopping the queue after this
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1157
		 * sees the new next_to_clean.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1158
		 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1159
		smp_mb();
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1160
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1161
		if (netif_queue_stopped(netdev) &&
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1162
		    !(test_bit(__E1000_DOWN, &adapter->state))) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1163
			netif_wake_queue(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1164
			++adapter->restart_queue;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1165
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1166
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1167
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1168
	if (adapter->detect_tx_hung) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1169
		/* Detect a transmit hang in hardware, this serializes the
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1170
		 * check with the clearing of time_stamp and movement of i
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1171
		 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1172
		adapter->detect_tx_hung = false;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1173
		if (tx_ring->buffer_info[i].time_stamp &&
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1174
		    time_after(jiffies, tx_ring->buffer_info[i].time_stamp
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1175
			       + (adapter->tx_timeout_factor * HZ)) &&
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1176
		    !(er32(STATUS) & E1000_STATUS_TXOFF))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1177
			schedule_work(&adapter->print_hang_task);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1178
		else
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1179
			adapter->tx_hang_recheck = false;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1180
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1181
	adapter->total_tx_bytes += total_tx_bytes;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1182
	adapter->total_tx_packets += total_tx_packets;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1183
	return count < tx_ring->count;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1184
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1185
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1186
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1187
 * e1000_clean_rx_irq_ps - Send received data up the network stack; packet split
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1188
 * @rx_ring: Rx descriptor ring
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1189
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1190
 * the return value indicates whether actual cleaning was done, there
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1191
 * is no guarantee that everything was cleaned
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1192
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1193
static bool e1000_clean_rx_irq_ps(struct e1000_ring *rx_ring, int *work_done,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1194
				  int work_to_do)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1195
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1196
	struct e1000_adapter *adapter = rx_ring->adapter;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1197
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1198
	union e1000_rx_desc_packet_split *rx_desc, *next_rxd;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1199
	struct net_device *netdev = adapter->netdev;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1200
	struct pci_dev *pdev = adapter->pdev;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1201
	struct e1000_buffer *buffer_info, *next_buffer;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1202
	struct e1000_ps_page *ps_page;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1203
	struct sk_buff *skb;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1204
	unsigned int i, j;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1205
	u32 length, staterr;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1206
	int cleaned_count = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1207
	bool cleaned = false;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1208
	unsigned int total_rx_bytes = 0, total_rx_packets = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1209
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1210
	i = rx_ring->next_to_clean;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1211
	rx_desc = E1000_RX_DESC_PS(*rx_ring, i);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1212
	staterr = le32_to_cpu(rx_desc->wb.middle.status_error);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1213
	buffer_info = &rx_ring->buffer_info[i];
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1214
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1215
	while (staterr & E1000_RXD_STAT_DD) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1216
		if (*work_done >= work_to_do)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1217
			break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1218
		(*work_done)++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1219
		skb = buffer_info->skb;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1220
		rmb();	/* read descriptor and rx_buffer_info after status DD */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1221
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1222
		/* in the packet split case this is header only */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1223
		prefetch(skb->data - NET_IP_ALIGN);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1224
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1225
		i++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1226
		if (i == rx_ring->count)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1227
			i = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1228
		next_rxd = E1000_RX_DESC_PS(*rx_ring, i);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1229
		prefetch(next_rxd);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1230
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1231
		next_buffer = &rx_ring->buffer_info[i];
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1232
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1233
		cleaned = true;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1234
		cleaned_count++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1235
		dma_unmap_single(&pdev->dev, buffer_info->dma,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1236
				 adapter->rx_ps_bsize0, DMA_FROM_DEVICE);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1237
		buffer_info->dma = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1238
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1239
		/* see !EOP comment in other Rx routine */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1240
		if (!(staterr & E1000_RXD_STAT_EOP))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1241
			adapter->flags2 |= FLAG2_IS_DISCARDING;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1242
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1243
		if (adapter->flags2 & FLAG2_IS_DISCARDING) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1244
			e_dbg("Packet Split buffers didn't pick up the full packet\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1245
			dev_kfree_skb_irq(skb);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1246
			if (staterr & E1000_RXD_STAT_EOP)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1247
				adapter->flags2 &= ~FLAG2_IS_DISCARDING;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1248
			goto next_desc;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1249
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1250
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1251
		if (unlikely((staterr & E1000_RXDEXT_ERR_FRAME_ERR_MASK) &&
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1252
			     !(netdev->features & NETIF_F_RXALL))) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1253
			dev_kfree_skb_irq(skb);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1254
			goto next_desc;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1255
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1256
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1257
		length = le16_to_cpu(rx_desc->wb.middle.length0);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1258
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1259
		if (!length) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1260
			e_dbg("Last part of the packet spanning multiple descriptors\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1261
			dev_kfree_skb_irq(skb);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1262
			goto next_desc;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1263
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1264
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1265
		/* Good Receive */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1266
		skb_put(skb, length);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1267
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1268
		{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1269
			/* this looks ugly, but it seems compiler issues make
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1270
			 * it more efficient than reusing j
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1271
			 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1272
			int l1 = le16_to_cpu(rx_desc->wb.upper.length[0]);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1273
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1274
			/* page alloc/put takes too long and effects small
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1275
			 * packet throughput, so unsplit small packets and
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1276
			 * save the alloc/put only valid in softirq (napi)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1277
			 * context to call kmap_*
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1278
			 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1279
			if (l1 && (l1 <= copybreak) &&
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1280
			    ((length + l1) <= adapter->rx_ps_bsize0)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1281
				u8 *vaddr;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1282
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1283
				ps_page = &buffer_info->ps_pages[0];
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1284
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1285
				/* there is no documentation about how to call
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1286
				 * kmap_atomic, so we can't hold the mapping
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1287
				 * very long
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1288
				 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1289
				dma_sync_single_for_cpu(&pdev->dev,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1290
							ps_page->dma,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1291
							PAGE_SIZE,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1292
							DMA_FROM_DEVICE);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1293
				vaddr = kmap_atomic(ps_page->page);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1294
				memcpy(skb_tail_pointer(skb), vaddr, l1);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1295
				kunmap_atomic(vaddr);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1296
				dma_sync_single_for_device(&pdev->dev,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1297
							   ps_page->dma,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1298
							   PAGE_SIZE,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1299
							   DMA_FROM_DEVICE);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1300
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1301
				/* remove the CRC */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1302
				if (!(adapter->flags2 & FLAG2_CRC_STRIPPING)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1303
					if (!(netdev->features & NETIF_F_RXFCS))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1304
						l1 -= 4;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1305
				}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1306
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1307
				skb_put(skb, l1);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1308
				goto copydone;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1309
			} /* if */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1310
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1311
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1312
		for (j = 0; j < PS_PAGE_BUFFERS; j++) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1313
			length = le16_to_cpu(rx_desc->wb.upper.length[j]);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1314
			if (!length)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1315
				break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1316
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1317
			ps_page = &buffer_info->ps_pages[j];
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1318
			dma_unmap_page(&pdev->dev, ps_page->dma, PAGE_SIZE,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1319
				       DMA_FROM_DEVICE);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1320
			ps_page->dma = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1321
			skb_fill_page_desc(skb, j, ps_page->page, 0, length);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1322
			ps_page->page = NULL;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1323
			skb->len += length;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1324
			skb->data_len += length;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1325
			skb->truesize += PAGE_SIZE;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1326
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1327
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1328
		/* strip the ethernet crc, problem is we're using pages now so
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1329
		 * this whole operation can get a little cpu intensive
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1330
		 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1331
		if (!(adapter->flags2 & FLAG2_CRC_STRIPPING)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1332
			if (!(netdev->features & NETIF_F_RXFCS))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1333
				pskb_trim(skb, skb->len - 4);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1334
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1335
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1336
copydone:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1337
		total_rx_bytes += skb->len;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1338
		total_rx_packets++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1339
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1340
		e1000_rx_checksum(adapter, staterr, skb);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1341
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1342
		e1000_rx_hash(netdev, rx_desc->wb.lower.hi_dword.rss, skb);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1343
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1344
		if (rx_desc->wb.upper.header_status &
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1345
			   cpu_to_le16(E1000_RXDPS_HDRSTAT_HDRSP))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1346
			adapter->rx_hdr_split++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1347
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1348
		e1000_receive_skb(adapter, netdev, skb,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1349
				  staterr, rx_desc->wb.middle.vlan);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1350
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1351
next_desc:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1352
		rx_desc->wb.middle.status_error &= cpu_to_le32(~0xFF);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1353
		buffer_info->skb = NULL;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1354
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1355
		/* return some buffers to hardware, one at a time is too slow */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1356
		if (cleaned_count >= E1000_RX_BUFFER_WRITE) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1357
			adapter->alloc_rx_buf(rx_ring, cleaned_count,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1358
					      GFP_ATOMIC);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1359
			cleaned_count = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1360
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1361
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1362
		/* use prefetched values */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1363
		rx_desc = next_rxd;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1364
		buffer_info = next_buffer;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1365
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1366
		staterr = le32_to_cpu(rx_desc->wb.middle.status_error);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1367
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1368
	rx_ring->next_to_clean = i;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1369
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1370
	cleaned_count = e1000_desc_unused(rx_ring);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1371
	if (cleaned_count)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1372
		adapter->alloc_rx_buf(rx_ring, cleaned_count, GFP_ATOMIC);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1373
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1374
	adapter->total_rx_bytes += total_rx_bytes;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1375
	adapter->total_rx_packets += total_rx_packets;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1376
	return cleaned;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1377
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1378
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1379
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1380
 * e1000_consume_page - helper function
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1381
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1382
static void e1000_consume_page(struct e1000_buffer *bi, struct sk_buff *skb,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1383
                               u16 length)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1384
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1385
	bi->page = NULL;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1386
	skb->len += length;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1387
	skb->data_len += length;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1388
	skb->truesize += PAGE_SIZE;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1389
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1390
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1391
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1392
 * e1000_clean_jumbo_rx_irq - Send received data up the network stack; legacy
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1393
 * @adapter: board private structure
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1394
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1395
 * the return value indicates whether actual cleaning was done, there
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1396
 * is no guarantee that everything was cleaned
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1397
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1398
static bool e1000_clean_jumbo_rx_irq(struct e1000_ring *rx_ring, int *work_done,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1399
				     int work_to_do)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1400
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1401
	struct e1000_adapter *adapter = rx_ring->adapter;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1402
	struct net_device *netdev = adapter->netdev;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1403
	struct pci_dev *pdev = adapter->pdev;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1404
	union e1000_rx_desc_extended *rx_desc, *next_rxd;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1405
	struct e1000_buffer *buffer_info, *next_buffer;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1406
	u32 length, staterr;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1407
	unsigned int i;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1408
	int cleaned_count = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1409
	bool cleaned = false;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1410
	unsigned int total_rx_bytes=0, total_rx_packets=0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1411
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1412
	i = rx_ring->next_to_clean;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1413
	rx_desc = E1000_RX_DESC_EXT(*rx_ring, i);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1414
	staterr = le32_to_cpu(rx_desc->wb.upper.status_error);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1415
	buffer_info = &rx_ring->buffer_info[i];
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1416
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1417
	while (staterr & E1000_RXD_STAT_DD) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1418
		struct sk_buff *skb;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1419
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1420
		if (*work_done >= work_to_do)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1421
			break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1422
		(*work_done)++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1423
		rmb();	/* read descriptor and rx_buffer_info after status DD */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1424
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1425
		skb = buffer_info->skb;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1426
		buffer_info->skb = NULL;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1427
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1428
		++i;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1429
		if (i == rx_ring->count)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1430
			i = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1431
		next_rxd = E1000_RX_DESC_EXT(*rx_ring, i);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1432
		prefetch(next_rxd);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1433
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1434
		next_buffer = &rx_ring->buffer_info[i];
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1435
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1436
		cleaned = true;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1437
		cleaned_count++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1438
		dma_unmap_page(&pdev->dev, buffer_info->dma, PAGE_SIZE,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1439
			       DMA_FROM_DEVICE);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1440
		buffer_info->dma = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1441
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1442
		length = le16_to_cpu(rx_desc->wb.upper.length);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1443
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1444
		/* errors is only valid for DD + EOP descriptors */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1445
		if (unlikely((staterr & E1000_RXD_STAT_EOP) &&
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1446
			     ((staterr & E1000_RXDEXT_ERR_FRAME_ERR_MASK) &&
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1447
			      !(netdev->features & NETIF_F_RXALL)))) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1448
			/* recycle both page and skb */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1449
			buffer_info->skb = skb;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1450
			/* an error means any chain goes out the window too */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1451
			if (rx_ring->rx_skb_top)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1452
				dev_kfree_skb_irq(rx_ring->rx_skb_top);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1453
			rx_ring->rx_skb_top = NULL;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1454
			goto next_desc;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1455
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1456
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1457
#define rxtop (rx_ring->rx_skb_top)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1458
		if (!(staterr & E1000_RXD_STAT_EOP)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1459
			/* this descriptor is only the beginning (or middle) */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1460
			if (!rxtop) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1461
				/* this is the beginning of a chain */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1462
				rxtop = skb;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1463
				skb_fill_page_desc(rxtop, 0, buffer_info->page,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1464
				                   0, length);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1465
			} else {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1466
				/* this is the middle of a chain */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1467
				skb_fill_page_desc(rxtop,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1468
				    skb_shinfo(rxtop)->nr_frags,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1469
				    buffer_info->page, 0, length);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1470
				/* re-use the skb, only consumed the page */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1471
				buffer_info->skb = skb;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1472
			}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1473
			e1000_consume_page(buffer_info, rxtop, length);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1474
			goto next_desc;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1475
		} else {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1476
			if (rxtop) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1477
				/* end of the chain */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1478
				skb_fill_page_desc(rxtop,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1479
				    skb_shinfo(rxtop)->nr_frags,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1480
				    buffer_info->page, 0, length);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1481
				/* re-use the current skb, we only consumed the
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1482
				 * page
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1483
				 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1484
				buffer_info->skb = skb;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1485
				skb = rxtop;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1486
				rxtop = NULL;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1487
				e1000_consume_page(buffer_info, skb, length);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1488
			} else {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1489
				/* no chain, got EOP, this buf is the packet
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1490
				 * copybreak to save the put_page/alloc_page
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1491
				 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1492
				if (length <= copybreak &&
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1493
				    skb_tailroom(skb) >= length) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1494
					u8 *vaddr;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1495
					vaddr = kmap_atomic(buffer_info->page);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1496
					memcpy(skb_tail_pointer(skb), vaddr,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1497
					       length);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1498
					kunmap_atomic(vaddr);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1499
					/* re-use the page, so don't erase
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1500
					 * buffer_info->page
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1501
					 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1502
					skb_put(skb, length);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1503
				} else {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1504
					skb_fill_page_desc(skb, 0,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1505
					                   buffer_info->page, 0,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1506
				                           length);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1507
					e1000_consume_page(buffer_info, skb,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1508
					                   length);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1509
				}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1510
			}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1511
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1512
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1513
		/* Receive Checksum Offload */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1514
		e1000_rx_checksum(adapter, staterr, skb);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1515
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1516
		e1000_rx_hash(netdev, rx_desc->wb.lower.hi_dword.rss, skb);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1517
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1518
		/* probably a little skewed due to removing CRC */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1519
		total_rx_bytes += skb->len;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1520
		total_rx_packets++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1521
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1522
		/* eth type trans needs skb->data to point to something */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1523
		if (!pskb_may_pull(skb, ETH_HLEN)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1524
			e_err("pskb_may_pull failed.\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1525
			dev_kfree_skb_irq(skb);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1526
			goto next_desc;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1527
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1528
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1529
		e1000_receive_skb(adapter, netdev, skb, staterr,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1530
				  rx_desc->wb.upper.vlan);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1531
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1532
next_desc:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1533
		rx_desc->wb.upper.status_error &= cpu_to_le32(~0xFF);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1534
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1535
		/* return some buffers to hardware, one at a time is too slow */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1536
		if (unlikely(cleaned_count >= E1000_RX_BUFFER_WRITE)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1537
			adapter->alloc_rx_buf(rx_ring, cleaned_count,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1538
					      GFP_ATOMIC);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1539
			cleaned_count = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1540
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1541
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1542
		/* use prefetched values */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1543
		rx_desc = next_rxd;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1544
		buffer_info = next_buffer;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1545
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1546
		staterr = le32_to_cpu(rx_desc->wb.upper.status_error);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1547
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1548
	rx_ring->next_to_clean = i;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1549
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1550
	cleaned_count = e1000_desc_unused(rx_ring);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1551
	if (cleaned_count)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1552
		adapter->alloc_rx_buf(rx_ring, cleaned_count, GFP_ATOMIC);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1553
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1554
	adapter->total_rx_bytes += total_rx_bytes;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1555
	adapter->total_rx_packets += total_rx_packets;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1556
	return cleaned;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1557
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1558
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1559
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1560
 * e1000_clean_rx_ring - Free Rx Buffers per Queue
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1561
 * @rx_ring: Rx descriptor ring
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1562
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1563
static void e1000_clean_rx_ring(struct e1000_ring *rx_ring)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1564
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1565
	struct e1000_adapter *adapter = rx_ring->adapter;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1566
	struct e1000_buffer *buffer_info;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1567
	struct e1000_ps_page *ps_page;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1568
	struct pci_dev *pdev = adapter->pdev;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1569
	unsigned int i, j;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1570
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1571
	/* Free all the Rx ring sk_buffs */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1572
	for (i = 0; i < rx_ring->count; i++) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1573
		buffer_info = &rx_ring->buffer_info[i];
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1574
		if (buffer_info->dma) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1575
			if (adapter->clean_rx == e1000_clean_rx_irq)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1576
				dma_unmap_single(&pdev->dev, buffer_info->dma,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1577
						 adapter->rx_buffer_len,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1578
						 DMA_FROM_DEVICE);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1579
			else if (adapter->clean_rx == e1000_clean_jumbo_rx_irq)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1580
				dma_unmap_page(&pdev->dev, buffer_info->dma,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1581
				               PAGE_SIZE,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1582
					       DMA_FROM_DEVICE);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1583
			else if (adapter->clean_rx == e1000_clean_rx_irq_ps)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1584
				dma_unmap_single(&pdev->dev, buffer_info->dma,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1585
						 adapter->rx_ps_bsize0,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1586
						 DMA_FROM_DEVICE);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1587
			buffer_info->dma = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1588
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1589
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1590
		if (buffer_info->page) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1591
			put_page(buffer_info->page);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1592
			buffer_info->page = NULL;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1593
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1594
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1595
		if (buffer_info->skb) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1596
			dev_kfree_skb(buffer_info->skb);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1597
			buffer_info->skb = NULL;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1598
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1599
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1600
		for (j = 0; j < PS_PAGE_BUFFERS; j++) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1601
			ps_page = &buffer_info->ps_pages[j];
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1602
			if (!ps_page->page)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1603
				break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1604
			dma_unmap_page(&pdev->dev, ps_page->dma, PAGE_SIZE,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1605
				       DMA_FROM_DEVICE);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1606
			ps_page->dma = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1607
			put_page(ps_page->page);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1608
			ps_page->page = NULL;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1609
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1610
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1611
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1612
	/* there also may be some cached data from a chained receive */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1613
	if (rx_ring->rx_skb_top) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1614
		dev_kfree_skb(rx_ring->rx_skb_top);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1615
		rx_ring->rx_skb_top = NULL;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1616
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1617
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1618
	/* Zero out the descriptor ring */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1619
	memset(rx_ring->desc, 0, rx_ring->size);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1620
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1621
	rx_ring->next_to_clean = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1622
	rx_ring->next_to_use = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1623
	adapter->flags2 &= ~FLAG2_IS_DISCARDING;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1624
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1625
	writel(0, rx_ring->head);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1626
	if (rx_ring->adapter->flags2 & FLAG2_PCIM2PCI_ARBITER_WA)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1627
		e1000e_update_rdt_wa(rx_ring, 0);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1628
	else
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1629
		writel(0, rx_ring->tail);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1630
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1631
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1632
static void e1000e_downshift_workaround(struct work_struct *work)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1633
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1634
	struct e1000_adapter *adapter = container_of(work,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1635
					struct e1000_adapter, downshift_task);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1636
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1637
	if (test_bit(__E1000_DOWN, &adapter->state))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1638
		return;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1639
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1640
	e1000e_gig_downshift_workaround_ich8lan(&adapter->hw);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1641
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1642
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1643
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1644
 * e1000_intr_msi - Interrupt Handler
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1645
 * @irq: interrupt number
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1646
 * @data: pointer to a network interface device structure
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1647
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1648
static irqreturn_t e1000_intr_msi(int irq, void *data)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1649
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1650
	struct net_device *netdev = data;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1651
	struct e1000_adapter *adapter = netdev_priv(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1652
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1653
	u32 icr = er32(ICR);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1654
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1655
	/* read ICR disables interrupts using IAM */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1656
	if (icr & E1000_ICR_LSC) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1657
		hw->mac.get_link_status = true;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1658
		/* ICH8 workaround-- Call gig speed drop workaround on cable
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1659
		 * disconnect (LSC) before accessing any PHY registers
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1660
		 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1661
		if ((adapter->flags & FLAG_LSC_GIG_SPEED_DROP) &&
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1662
		    (!(er32(STATUS) & E1000_STATUS_LU)))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1663
			schedule_work(&adapter->downshift_task);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1664
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1665
		/* 80003ES2LAN workaround-- For packet buffer work-around on
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1666
		 * link down event; disable receives here in the ISR and reset
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1667
		 * adapter in watchdog
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1668
		 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1669
		if (netif_carrier_ok(netdev) &&
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1670
		    adapter->flags & FLAG_RX_NEEDS_RESTART) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1671
			/* disable receives */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1672
			u32 rctl = er32(RCTL);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1673
			ew32(RCTL, rctl & ~E1000_RCTL_EN);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1674
			adapter->flags |= FLAG_RX_RESTART_NOW;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1675
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1676
		/* guard against interrupt when we're going down */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1677
		if (!test_bit(__E1000_DOWN, &adapter->state))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1678
			mod_timer(&adapter->watchdog_timer, jiffies + 1);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1679
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1680
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1681
	/* Reset on uncorrectable ECC error */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1682
	if ((icr & E1000_ICR_ECCER) && (hw->mac.type == e1000_pch_lpt)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1683
		u32 pbeccsts = er32(PBECCSTS);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1684
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1685
		adapter->corr_errors +=
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1686
		    pbeccsts & E1000_PBECCSTS_CORR_ERR_CNT_MASK;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1687
		adapter->uncorr_errors +=
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1688
		    (pbeccsts & E1000_PBECCSTS_UNCORR_ERR_CNT_MASK) >>
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1689
		    E1000_PBECCSTS_UNCORR_ERR_CNT_SHIFT;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1690
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1691
		/* Do the reset outside of interrupt context */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1692
		schedule_work(&adapter->reset_task);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1693
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1694
		/* return immediately since reset is imminent */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1695
		return IRQ_HANDLED;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1696
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1697
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1698
	if (napi_schedule_prep(&adapter->napi)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1699
		adapter->total_tx_bytes = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1700
		adapter->total_tx_packets = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1701
		adapter->total_rx_bytes = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1702
		adapter->total_rx_packets = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1703
		__napi_schedule(&adapter->napi);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1704
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1705
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1706
	return IRQ_HANDLED;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1707
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1708
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1709
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1710
 * e1000_intr - Interrupt Handler
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1711
 * @irq: interrupt number
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1712
 * @data: pointer to a network interface device structure
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1713
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1714
static irqreturn_t e1000_intr(int irq, void *data)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1715
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1716
	struct net_device *netdev = data;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1717
	struct e1000_adapter *adapter = netdev_priv(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1718
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1719
	u32 rctl, icr = er32(ICR);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1720
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1721
	if (!icr || test_bit(__E1000_DOWN, &adapter->state))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1722
		return IRQ_NONE;  /* Not our interrupt */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1723
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1724
	/* IMS will not auto-mask if INT_ASSERTED is not set, and if it is
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1725
	 * not set, then the adapter didn't send an interrupt
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1726
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1727
	if (!(icr & E1000_ICR_INT_ASSERTED))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1728
		return IRQ_NONE;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1729
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1730
	/* Interrupt Auto-Mask...upon reading ICR,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1731
	 * interrupts are masked.  No need for the
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1732
	 * IMC write
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1733
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1734
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1735
	if (icr & E1000_ICR_LSC) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1736
		hw->mac.get_link_status = true;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1737
		/* ICH8 workaround-- Call gig speed drop workaround on cable
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1738
		 * disconnect (LSC) before accessing any PHY registers
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1739
		 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1740
		if ((adapter->flags & FLAG_LSC_GIG_SPEED_DROP) &&
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1741
		    (!(er32(STATUS) & E1000_STATUS_LU)))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1742
			schedule_work(&adapter->downshift_task);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1743
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1744
		/* 80003ES2LAN workaround--
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1745
		 * For packet buffer work-around on link down event;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1746
		 * disable receives here in the ISR and
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1747
		 * reset adapter in watchdog
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1748
		 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1749
		if (netif_carrier_ok(netdev) &&
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1750
		    (adapter->flags & FLAG_RX_NEEDS_RESTART)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1751
			/* disable receives */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1752
			rctl = er32(RCTL);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1753
			ew32(RCTL, rctl & ~E1000_RCTL_EN);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1754
			adapter->flags |= FLAG_RX_RESTART_NOW;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1755
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1756
		/* guard against interrupt when we're going down */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1757
		if (!test_bit(__E1000_DOWN, &adapter->state))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1758
			mod_timer(&adapter->watchdog_timer, jiffies + 1);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1759
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1760
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1761
	/* Reset on uncorrectable ECC error */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1762
	if ((icr & E1000_ICR_ECCER) && (hw->mac.type == e1000_pch_lpt)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1763
		u32 pbeccsts = er32(PBECCSTS);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1764
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1765
		adapter->corr_errors +=
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1766
		    pbeccsts & E1000_PBECCSTS_CORR_ERR_CNT_MASK;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1767
		adapter->uncorr_errors +=
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1768
		    (pbeccsts & E1000_PBECCSTS_UNCORR_ERR_CNT_MASK) >>
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1769
		    E1000_PBECCSTS_UNCORR_ERR_CNT_SHIFT;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1770
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1771
		/* Do the reset outside of interrupt context */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1772
		schedule_work(&adapter->reset_task);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1773
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1774
		/* return immediately since reset is imminent */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1775
		return IRQ_HANDLED;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1776
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1777
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1778
	if (napi_schedule_prep(&adapter->napi)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1779
		adapter->total_tx_bytes = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1780
		adapter->total_tx_packets = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1781
		adapter->total_rx_bytes = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1782
		adapter->total_rx_packets = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1783
		__napi_schedule(&adapter->napi);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1784
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1785
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1786
	return IRQ_HANDLED;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1787
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1788
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1789
static irqreturn_t e1000_msix_other(int irq, void *data)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1790
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1791
	struct net_device *netdev = data;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1792
	struct e1000_adapter *adapter = netdev_priv(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1793
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1794
	u32 icr = er32(ICR);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1795
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1796
	if (!(icr & E1000_ICR_INT_ASSERTED)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1797
		if (!test_bit(__E1000_DOWN, &adapter->state))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1798
			ew32(IMS, E1000_IMS_OTHER);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1799
		return IRQ_NONE;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1800
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1801
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1802
	if (icr & adapter->eiac_mask)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1803
		ew32(ICS, (icr & adapter->eiac_mask));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1804
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1805
	if (icr & E1000_ICR_OTHER) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1806
		if (!(icr & E1000_ICR_LSC))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1807
			goto no_link_interrupt;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1808
		hw->mac.get_link_status = true;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1809
		/* guard against interrupt when we're going down */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1810
		if (!test_bit(__E1000_DOWN, &adapter->state))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1811
			mod_timer(&adapter->watchdog_timer, jiffies + 1);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1812
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1813
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1814
no_link_interrupt:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1815
	if (!test_bit(__E1000_DOWN, &adapter->state))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1816
		ew32(IMS, E1000_IMS_LSC | E1000_IMS_OTHER);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1817
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1818
	return IRQ_HANDLED;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1819
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1820
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1821
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1822
static irqreturn_t e1000_intr_msix_tx(int irq, void *data)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1823
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1824
	struct net_device *netdev = data;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1825
	struct e1000_adapter *adapter = netdev_priv(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1826
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1827
	struct e1000_ring *tx_ring = adapter->tx_ring;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1828
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1829
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1830
	adapter->total_tx_bytes = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1831
	adapter->total_tx_packets = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1832
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1833
	if (!e1000_clean_tx_irq(tx_ring))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1834
		/* Ring was not completely cleaned, so fire another interrupt */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1835
		ew32(ICS, tx_ring->ims_val);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1836
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1837
	return IRQ_HANDLED;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1838
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1839
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1840
static irqreturn_t e1000_intr_msix_rx(int irq, void *data)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1841
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1842
	struct net_device *netdev = data;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1843
	struct e1000_adapter *adapter = netdev_priv(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1844
	struct e1000_ring *rx_ring = adapter->rx_ring;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1845
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1846
	/* Write the ITR value calculated at the end of the
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1847
	 * previous interrupt.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1848
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1849
	if (rx_ring->set_itr) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1850
		writel(1000000000 / (rx_ring->itr_val * 256),
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1851
		       rx_ring->itr_register);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1852
		rx_ring->set_itr = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1853
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1854
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1855
	if (napi_schedule_prep(&adapter->napi)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1856
		adapter->total_rx_bytes = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1857
		adapter->total_rx_packets = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1858
		__napi_schedule(&adapter->napi);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1859
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1860
	return IRQ_HANDLED;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1861
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1862
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1863
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1864
 * e1000_configure_msix - Configure MSI-X hardware
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1865
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1866
 * e1000_configure_msix sets up the hardware to properly
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1867
 * generate MSI-X interrupts.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1868
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1869
static void e1000_configure_msix(struct e1000_adapter *adapter)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1870
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1871
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1872
	struct e1000_ring *rx_ring = adapter->rx_ring;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1873
	struct e1000_ring *tx_ring = adapter->tx_ring;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1874
	int vector = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1875
	u32 ctrl_ext, ivar = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1876
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1877
	adapter->eiac_mask = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1878
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1879
	/* Workaround issue with spurious interrupts on 82574 in MSI-X mode */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1880
	if (hw->mac.type == e1000_82574) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1881
		u32 rfctl = er32(RFCTL);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1882
		rfctl |= E1000_RFCTL_ACK_DIS;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1883
		ew32(RFCTL, rfctl);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1884
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1885
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1886
#define E1000_IVAR_INT_ALLOC_VALID	0x8
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1887
	/* Configure Rx vector */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1888
	rx_ring->ims_val = E1000_IMS_RXQ0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1889
	adapter->eiac_mask |= rx_ring->ims_val;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1890
	if (rx_ring->itr_val)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1891
		writel(1000000000 / (rx_ring->itr_val * 256),
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1892
		       rx_ring->itr_register);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1893
	else
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1894
		writel(1, rx_ring->itr_register);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1895
	ivar = E1000_IVAR_INT_ALLOC_VALID | vector;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1896
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1897
	/* Configure Tx vector */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1898
	tx_ring->ims_val = E1000_IMS_TXQ0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1899
	vector++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1900
	if (tx_ring->itr_val)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1901
		writel(1000000000 / (tx_ring->itr_val * 256),
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1902
		       tx_ring->itr_register);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1903
	else
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1904
		writel(1, tx_ring->itr_register);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1905
	adapter->eiac_mask |= tx_ring->ims_val;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1906
	ivar |= ((E1000_IVAR_INT_ALLOC_VALID | vector) << 8);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1907
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1908
	/* set vector for Other Causes, e.g. link changes */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1909
	vector++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1910
	ivar |= ((E1000_IVAR_INT_ALLOC_VALID | vector) << 16);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1911
	if (rx_ring->itr_val)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1912
		writel(1000000000 / (rx_ring->itr_val * 256),
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1913
		       hw->hw_addr + E1000_EITR_82574(vector));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1914
	else
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1915
		writel(1, hw->hw_addr + E1000_EITR_82574(vector));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1916
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1917
	/* Cause Tx interrupts on every write back */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1918
	ivar |= (1 << 31);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1919
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1920
	ew32(IVAR, ivar);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1921
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1922
	/* enable MSI-X PBA support */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1923
	ctrl_ext = er32(CTRL_EXT);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1924
	ctrl_ext |= E1000_CTRL_EXT_PBA_CLR;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1925
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1926
	/* Auto-Mask Other interrupts upon ICR read */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1927
#define E1000_EIAC_MASK_82574   0x01F00000
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1928
	ew32(IAM, ~E1000_EIAC_MASK_82574 | E1000_IMS_OTHER);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1929
	ctrl_ext |= E1000_CTRL_EXT_EIAME;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1930
	ew32(CTRL_EXT, ctrl_ext);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1931
	e1e_flush();
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1932
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1933
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1934
void e1000e_reset_interrupt_capability(struct e1000_adapter *adapter)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1935
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1936
	if (adapter->msix_entries) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1937
		pci_disable_msix(adapter->pdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1938
		kfree(adapter->msix_entries);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1939
		adapter->msix_entries = NULL;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1940
	} else if (adapter->flags & FLAG_MSI_ENABLED) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1941
		pci_disable_msi(adapter->pdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1942
		adapter->flags &= ~FLAG_MSI_ENABLED;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1943
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1944
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1945
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1946
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1947
 * e1000e_set_interrupt_capability - set MSI or MSI-X if supported
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1948
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1949
 * Attempt to configure interrupts using the best available
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1950
 * capabilities of the hardware and kernel.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1951
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1952
void e1000e_set_interrupt_capability(struct e1000_adapter *adapter)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1953
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1954
	int err;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1955
	int i;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1956
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1957
	switch (adapter->int_mode) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1958
	case E1000E_INT_MODE_MSIX:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1959
		if (adapter->flags & FLAG_HAS_MSIX) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1960
			adapter->num_vectors = 3; /* RxQ0, TxQ0 and other */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1961
			adapter->msix_entries = kcalloc(adapter->num_vectors,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1962
						      sizeof(struct msix_entry),
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1963
						      GFP_KERNEL);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1964
			if (adapter->msix_entries) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1965
				for (i = 0; i < adapter->num_vectors; i++)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1966
					adapter->msix_entries[i].entry = i;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1967
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1968
				err = pci_enable_msix(adapter->pdev,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1969
						      adapter->msix_entries,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1970
						      adapter->num_vectors);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1971
				if (err == 0)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1972
					return;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1973
			}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1974
			/* MSI-X failed, so fall through and try MSI */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1975
			e_err("Failed to initialize MSI-X interrupts.  Falling back to MSI interrupts.\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1976
			e1000e_reset_interrupt_capability(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1977
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1978
		adapter->int_mode = E1000E_INT_MODE_MSI;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1979
		/* Fall through */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1980
	case E1000E_INT_MODE_MSI:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1981
		if (!pci_enable_msi(adapter->pdev)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1982
			adapter->flags |= FLAG_MSI_ENABLED;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1983
		} else {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1984
			adapter->int_mode = E1000E_INT_MODE_LEGACY;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1985
			e_err("Failed to initialize MSI interrupts.  Falling back to legacy interrupts.\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1986
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1987
		/* Fall through */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1988
	case E1000E_INT_MODE_LEGACY:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1989
		/* Don't do anything; this is the system default */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1990
		break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1991
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1992
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1993
	/* store the number of vectors being used */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1994
	adapter->num_vectors = 1;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1995
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1996
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1997
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1998
 * e1000_request_msix - Initialize MSI-X interrupts
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1999
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2000
 * e1000_request_msix allocates MSI-X vectors and requests interrupts from the
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2001
 * kernel.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2002
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2003
static int e1000_request_msix(struct e1000_adapter *adapter)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2004
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2005
	struct net_device *netdev = adapter->netdev;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2006
	int err = 0, vector = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2007
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2008
	if (strlen(netdev->name) < (IFNAMSIZ - 5))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2009
		snprintf(adapter->rx_ring->name,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2010
			 sizeof(adapter->rx_ring->name) - 1,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2011
			 "%s-rx-0", netdev->name);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2012
	else
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2013
		memcpy(adapter->rx_ring->name, netdev->name, IFNAMSIZ);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2014
	err = request_irq(adapter->msix_entries[vector].vector,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2015
			  e1000_intr_msix_rx, 0, adapter->rx_ring->name,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2016
			  netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2017
	if (err)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2018
		return err;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2019
	adapter->rx_ring->itr_register = adapter->hw.hw_addr +
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2020
	    E1000_EITR_82574(vector);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2021
	adapter->rx_ring->itr_val = adapter->itr;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2022
	vector++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2023
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2024
	if (strlen(netdev->name) < (IFNAMSIZ - 5))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2025
		snprintf(adapter->tx_ring->name,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2026
			 sizeof(adapter->tx_ring->name) - 1,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2027
			 "%s-tx-0", netdev->name);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2028
	else
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2029
		memcpy(adapter->tx_ring->name, netdev->name, IFNAMSIZ);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2030
	err = request_irq(adapter->msix_entries[vector].vector,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2031
			  e1000_intr_msix_tx, 0, adapter->tx_ring->name,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2032
			  netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2033
	if (err)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2034
		return err;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2035
	adapter->tx_ring->itr_register = adapter->hw.hw_addr +
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2036
	    E1000_EITR_82574(vector);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2037
	adapter->tx_ring->itr_val = adapter->itr;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2038
	vector++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2039
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2040
	err = request_irq(adapter->msix_entries[vector].vector,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2041
			  e1000_msix_other, 0, netdev->name, netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2042
	if (err)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2043
		return err;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2044
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2045
	e1000_configure_msix(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2046
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2047
	return 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2048
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2049
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2050
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2051
 * e1000_request_irq - initialize interrupts
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2052
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2053
 * Attempts to configure interrupts using the best available
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2054
 * capabilities of the hardware and kernel.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2055
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2056
static int e1000_request_irq(struct e1000_adapter *adapter)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2057
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2058
	struct net_device *netdev = adapter->netdev;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2059
	int err;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2060
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2061
	if (adapter->msix_entries) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2062
		err = e1000_request_msix(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2063
		if (!err)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2064
			return err;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2065
		/* fall back to MSI */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2066
		e1000e_reset_interrupt_capability(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2067
		adapter->int_mode = E1000E_INT_MODE_MSI;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2068
		e1000e_set_interrupt_capability(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2069
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2070
	if (adapter->flags & FLAG_MSI_ENABLED) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2071
		err = request_irq(adapter->pdev->irq, e1000_intr_msi, 0,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2072
				  netdev->name, netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2073
		if (!err)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2074
			return err;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2075
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2076
		/* fall back to legacy interrupt */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2077
		e1000e_reset_interrupt_capability(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2078
		adapter->int_mode = E1000E_INT_MODE_LEGACY;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2079
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2080
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2081
	err = request_irq(adapter->pdev->irq, e1000_intr, IRQF_SHARED,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2082
			  netdev->name, netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2083
	if (err)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2084
		e_err("Unable to allocate interrupt, Error: %d\n", err);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2085
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2086
	return err;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2087
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2088
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2089
static void e1000_free_irq(struct e1000_adapter *adapter)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2090
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2091
	struct net_device *netdev = adapter->netdev;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2092
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2093
	if (adapter->msix_entries) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2094
		int vector = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2095
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2096
		free_irq(adapter->msix_entries[vector].vector, netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2097
		vector++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2098
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2099
		free_irq(adapter->msix_entries[vector].vector, netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2100
		vector++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2101
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2102
		/* Other Causes interrupt vector */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2103
		free_irq(adapter->msix_entries[vector].vector, netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2104
		return;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2105
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2106
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2107
	free_irq(adapter->pdev->irq, netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2108
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2109
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2110
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2111
 * e1000_irq_disable - Mask off interrupt generation on the NIC
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2112
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2113
static void e1000_irq_disable(struct e1000_adapter *adapter)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2114
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2115
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2116
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2117
	ew32(IMC, ~0);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2118
	if (adapter->msix_entries)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2119
		ew32(EIAC_82574, 0);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2120
	e1e_flush();
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2121
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2122
	if (adapter->msix_entries) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2123
		int i;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2124
		for (i = 0; i < adapter->num_vectors; i++)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2125
			synchronize_irq(adapter->msix_entries[i].vector);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2126
	} else {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2127
		synchronize_irq(adapter->pdev->irq);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2128
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2129
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2130
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2131
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2132
 * e1000_irq_enable - Enable default interrupt generation settings
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2133
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2134
static void e1000_irq_enable(struct e1000_adapter *adapter)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2135
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2136
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2137
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2138
	if (adapter->msix_entries) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2139
		ew32(EIAC_82574, adapter->eiac_mask & E1000_EIAC_MASK_82574);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2140
		ew32(IMS, adapter->eiac_mask | E1000_IMS_OTHER | E1000_IMS_LSC);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2141
	} else if (hw->mac.type == e1000_pch_lpt) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2142
		ew32(IMS, IMS_ENABLE_MASK | E1000_IMS_ECCER);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2143
	} else {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2144
		ew32(IMS, IMS_ENABLE_MASK);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2145
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2146
	e1e_flush();
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2147
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2148
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2149
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2150
 * e1000e_get_hw_control - get control of the h/w from f/w
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2151
 * @adapter: address of board private structure
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2152
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2153
 * e1000e_get_hw_control sets {CTRL_EXT|SWSM}:DRV_LOAD bit.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2154
 * For ASF and Pass Through versions of f/w this means that
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2155
 * the driver is loaded. For AMT version (only with 82573)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2156
 * of the f/w this means that the network i/f is open.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2157
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2158
void e1000e_get_hw_control(struct e1000_adapter *adapter)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2159
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2160
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2161
	u32 ctrl_ext;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2162
	u32 swsm;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2163
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2164
	/* Let firmware know the driver has taken over */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2165
	if (adapter->flags & FLAG_HAS_SWSM_ON_LOAD) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2166
		swsm = er32(SWSM);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2167
		ew32(SWSM, swsm | E1000_SWSM_DRV_LOAD);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2168
	} else if (adapter->flags & FLAG_HAS_CTRLEXT_ON_LOAD) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2169
		ctrl_ext = er32(CTRL_EXT);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2170
		ew32(CTRL_EXT, ctrl_ext | E1000_CTRL_EXT_DRV_LOAD);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2171
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2172
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2173
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2174
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2175
 * e1000e_release_hw_control - release control of the h/w to f/w
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2176
 * @adapter: address of board private structure
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2177
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2178
 * e1000e_release_hw_control resets {CTRL_EXT|SWSM}:DRV_LOAD bit.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2179
 * For ASF and Pass Through versions of f/w this means that the
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2180
 * driver is no longer loaded. For AMT version (only with 82573) i
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2181
 * of the f/w this means that the network i/f is closed.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2182
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2183
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2184
void e1000e_release_hw_control(struct e1000_adapter *adapter)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2185
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2186
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2187
	u32 ctrl_ext;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2188
	u32 swsm;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2189
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2190
	/* Let firmware taken over control of h/w */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2191
	if (adapter->flags & FLAG_HAS_SWSM_ON_LOAD) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2192
		swsm = er32(SWSM);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2193
		ew32(SWSM, swsm & ~E1000_SWSM_DRV_LOAD);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2194
	} else if (adapter->flags & FLAG_HAS_CTRLEXT_ON_LOAD) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2195
		ctrl_ext = er32(CTRL_EXT);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2196
		ew32(CTRL_EXT, ctrl_ext & ~E1000_CTRL_EXT_DRV_LOAD);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2197
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2198
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2199
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2200
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2201
 * e1000_alloc_ring_dma - allocate memory for a ring structure
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2202
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2203
static int e1000_alloc_ring_dma(struct e1000_adapter *adapter,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2204
				struct e1000_ring *ring)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2205
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2206
	struct pci_dev *pdev = adapter->pdev;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2207
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2208
	ring->desc = dma_alloc_coherent(&pdev->dev, ring->size, &ring->dma,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2209
					GFP_KERNEL);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2210
	if (!ring->desc)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2211
		return -ENOMEM;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2212
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2213
	return 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2214
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2215
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2216
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2217
 * e1000e_setup_tx_resources - allocate Tx resources (Descriptors)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2218
 * @tx_ring: Tx descriptor ring
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2219
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2220
 * Return 0 on success, negative on failure
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2221
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2222
int e1000e_setup_tx_resources(struct e1000_ring *tx_ring)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2223
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2224
	struct e1000_adapter *adapter = tx_ring->adapter;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2225
	int err = -ENOMEM, size;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2226
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2227
	size = sizeof(struct e1000_buffer) * tx_ring->count;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2228
	tx_ring->buffer_info = vzalloc(size);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2229
	if (!tx_ring->buffer_info)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2230
		goto err;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2231
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2232
	/* round up to nearest 4K */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2233
	tx_ring->size = tx_ring->count * sizeof(struct e1000_tx_desc);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2234
	tx_ring->size = ALIGN(tx_ring->size, 4096);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2235
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2236
	err = e1000_alloc_ring_dma(adapter, tx_ring);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2237
	if (err)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2238
		goto err;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2239
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2240
	tx_ring->next_to_use = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2241
	tx_ring->next_to_clean = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2242
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2243
	return 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2244
err:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2245
	vfree(tx_ring->buffer_info);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2246
	e_err("Unable to allocate memory for the transmit descriptor ring\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2247
	return err;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2248
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2249
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2250
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2251
 * e1000e_setup_rx_resources - allocate Rx resources (Descriptors)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2252
 * @rx_ring: Rx descriptor ring
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2253
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2254
 * Returns 0 on success, negative on failure
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2255
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2256
int e1000e_setup_rx_resources(struct e1000_ring *rx_ring)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2257
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2258
	struct e1000_adapter *adapter = rx_ring->adapter;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2259
	struct e1000_buffer *buffer_info;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2260
	int i, size, desc_len, err = -ENOMEM;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2261
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2262
	size = sizeof(struct e1000_buffer) * rx_ring->count;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2263
	rx_ring->buffer_info = vzalloc(size);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2264
	if (!rx_ring->buffer_info)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2265
		goto err;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2266
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2267
	for (i = 0; i < rx_ring->count; i++) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2268
		buffer_info = &rx_ring->buffer_info[i];
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2269
		buffer_info->ps_pages = kcalloc(PS_PAGE_BUFFERS,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2270
						sizeof(struct e1000_ps_page),
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2271
						GFP_KERNEL);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2272
		if (!buffer_info->ps_pages)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2273
			goto err_pages;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2274
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2275
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2276
	desc_len = sizeof(union e1000_rx_desc_packet_split);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2277
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2278
	/* Round up to nearest 4K */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2279
	rx_ring->size = rx_ring->count * desc_len;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2280
	rx_ring->size = ALIGN(rx_ring->size, 4096);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2281
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2282
	err = e1000_alloc_ring_dma(adapter, rx_ring);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2283
	if (err)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2284
		goto err_pages;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2285
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2286
	rx_ring->next_to_clean = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2287
	rx_ring->next_to_use = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2288
	rx_ring->rx_skb_top = NULL;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2289
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2290
	return 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2291
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2292
err_pages:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2293
	for (i = 0; i < rx_ring->count; i++) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2294
		buffer_info = &rx_ring->buffer_info[i];
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2295
		kfree(buffer_info->ps_pages);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2296
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2297
err:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2298
	vfree(rx_ring->buffer_info);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2299
	e_err("Unable to allocate memory for the receive descriptor ring\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2300
	return err;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2301
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2302
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2303
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2304
 * e1000_clean_tx_ring - Free Tx Buffers
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2305
 * @tx_ring: Tx descriptor ring
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2306
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2307
static void e1000_clean_tx_ring(struct e1000_ring *tx_ring)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2308
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2309
	struct e1000_adapter *adapter = tx_ring->adapter;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2310
	struct e1000_buffer *buffer_info;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2311
	unsigned long size;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2312
	unsigned int i;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2313
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2314
	for (i = 0; i < tx_ring->count; i++) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2315
		buffer_info = &tx_ring->buffer_info[i];
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2316
		e1000_put_txbuf(tx_ring, buffer_info);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2317
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2318
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2319
	netdev_reset_queue(adapter->netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2320
	size = sizeof(struct e1000_buffer) * tx_ring->count;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2321
	memset(tx_ring->buffer_info, 0, size);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2322
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2323
	memset(tx_ring->desc, 0, tx_ring->size);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2324
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2325
	tx_ring->next_to_use = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2326
	tx_ring->next_to_clean = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2327
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2328
	writel(0, tx_ring->head);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2329
	if (tx_ring->adapter->flags2 & FLAG2_PCIM2PCI_ARBITER_WA)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2330
		e1000e_update_tdt_wa(tx_ring, 0);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2331
	else
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2332
		writel(0, tx_ring->tail);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2333
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2334
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2335
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2336
 * e1000e_free_tx_resources - Free Tx Resources per Queue
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2337
 * @tx_ring: Tx descriptor ring
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2338
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2339
 * Free all transmit software resources
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2340
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2341
void e1000e_free_tx_resources(struct e1000_ring *tx_ring)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2342
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2343
	struct e1000_adapter *adapter = tx_ring->adapter;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2344
	struct pci_dev *pdev = adapter->pdev;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2345
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2346
	e1000_clean_tx_ring(tx_ring);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2347
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2348
	vfree(tx_ring->buffer_info);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2349
	tx_ring->buffer_info = NULL;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2350
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2351
	dma_free_coherent(&pdev->dev, tx_ring->size, tx_ring->desc,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2352
			  tx_ring->dma);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2353
	tx_ring->desc = NULL;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2354
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2355
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2356
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2357
 * e1000e_free_rx_resources - Free Rx Resources
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2358
 * @rx_ring: Rx descriptor ring
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2359
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2360
 * Free all receive software resources
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2361
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2362
void e1000e_free_rx_resources(struct e1000_ring *rx_ring)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2363
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2364
	struct e1000_adapter *adapter = rx_ring->adapter;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2365
	struct pci_dev *pdev = adapter->pdev;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2366
	int i;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2367
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2368
	e1000_clean_rx_ring(rx_ring);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2369
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2370
	for (i = 0; i < rx_ring->count; i++)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2371
		kfree(rx_ring->buffer_info[i].ps_pages);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2372
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2373
	vfree(rx_ring->buffer_info);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2374
	rx_ring->buffer_info = NULL;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2375
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2376
	dma_free_coherent(&pdev->dev, rx_ring->size, rx_ring->desc,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2377
			  rx_ring->dma);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2378
	rx_ring->desc = NULL;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2379
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2380
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2381
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2382
 * e1000_update_itr - update the dynamic ITR value based on statistics
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2383
 * @adapter: pointer to adapter
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2384
 * @itr_setting: current adapter->itr
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2385
 * @packets: the number of packets during this measurement interval
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2386
 * @bytes: the number of bytes during this measurement interval
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2387
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2388
 *      Stores a new ITR value based on packets and byte
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2389
 *      counts during the last interrupt.  The advantage of per interrupt
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2390
 *      computation is faster updates and more accurate ITR for the current
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2391
 *      traffic pattern.  Constants in this function were computed
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2392
 *      based on theoretical maximum wire speed and thresholds were set based
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2393
 *      on testing data as well as attempting to minimize response time
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2394
 *      while increasing bulk throughput.  This functionality is controlled
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2395
 *      by the InterruptThrottleRate module parameter.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2396
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2397
static unsigned int e1000_update_itr(struct e1000_adapter *adapter,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2398
				     u16 itr_setting, int packets,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2399
				     int bytes)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2400
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2401
	unsigned int retval = itr_setting;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2402
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2403
	if (packets == 0)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2404
		return itr_setting;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2405
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2406
	switch (itr_setting) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2407
	case lowest_latency:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2408
		/* handle TSO and jumbo frames */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2409
		if (bytes/packets > 8000)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2410
			retval = bulk_latency;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2411
		else if ((packets < 5) && (bytes > 512))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2412
			retval = low_latency;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2413
		break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2414
	case low_latency:  /* 50 usec aka 20000 ints/s */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2415
		if (bytes > 10000) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2416
			/* this if handles the TSO accounting */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2417
			if (bytes/packets > 8000)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2418
				retval = bulk_latency;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2419
			else if ((packets < 10) || ((bytes/packets) > 1200))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2420
				retval = bulk_latency;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2421
			else if ((packets > 35))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2422
				retval = lowest_latency;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2423
		} else if (bytes/packets > 2000) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2424
			retval = bulk_latency;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2425
		} else if (packets <= 2 && bytes < 512) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2426
			retval = lowest_latency;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2427
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2428
		break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2429
	case bulk_latency: /* 250 usec aka 4000 ints/s */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2430
		if (bytes > 25000) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2431
			if (packets > 35)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2432
				retval = low_latency;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2433
		} else if (bytes < 6000) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2434
			retval = low_latency;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2435
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2436
		break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2437
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2438
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2439
	return retval;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2440
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2441
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2442
static void e1000_set_itr(struct e1000_adapter *adapter)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2443
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2444
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2445
	u16 current_itr;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2446
	u32 new_itr = adapter->itr;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2447
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2448
	/* for non-gigabit speeds, just fix the interrupt rate at 4000 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2449
	if (adapter->link_speed != SPEED_1000) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2450
		current_itr = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2451
		new_itr = 4000;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2452
		goto set_itr_now;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2453
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2454
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2455
	if (adapter->flags2 & FLAG2_DISABLE_AIM) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2456
		new_itr = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2457
		goto set_itr_now;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2458
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2459
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2460
	adapter->tx_itr = e1000_update_itr(adapter,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2461
				    adapter->tx_itr,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2462
				    adapter->total_tx_packets,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2463
				    adapter->total_tx_bytes);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2464
	/* conservative mode (itr 3) eliminates the lowest_latency setting */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2465
	if (adapter->itr_setting == 3 && adapter->tx_itr == lowest_latency)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2466
		adapter->tx_itr = low_latency;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2467
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2468
	adapter->rx_itr = e1000_update_itr(adapter,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2469
				    adapter->rx_itr,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2470
				    adapter->total_rx_packets,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2471
				    adapter->total_rx_bytes);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2472
	/* conservative mode (itr 3) eliminates the lowest_latency setting */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2473
	if (adapter->itr_setting == 3 && adapter->rx_itr == lowest_latency)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2474
		adapter->rx_itr = low_latency;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2475
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2476
	current_itr = max(adapter->rx_itr, adapter->tx_itr);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2477
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2478
	switch (current_itr) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2479
	/* counts and packets in update_itr are dependent on these numbers */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2480
	case lowest_latency:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2481
		new_itr = 70000;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2482
		break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2483
	case low_latency:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2484
		new_itr = 20000; /* aka hwitr = ~200 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2485
		break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2486
	case bulk_latency:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2487
		new_itr = 4000;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2488
		break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2489
	default:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2490
		break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2491
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2492
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2493
set_itr_now:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2494
	if (new_itr != adapter->itr) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2495
		/* this attempts to bias the interrupt rate towards Bulk
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2496
		 * by adding intermediate steps when interrupt rate is
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2497
		 * increasing
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2498
		 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2499
		new_itr = new_itr > adapter->itr ?
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2500
			     min(adapter->itr + (new_itr >> 2), new_itr) :
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2501
			     new_itr;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2502
		adapter->itr = new_itr;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2503
		adapter->rx_ring->itr_val = new_itr;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2504
		if (adapter->msix_entries)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2505
			adapter->rx_ring->set_itr = 1;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2506
		else
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2507
			if (new_itr)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2508
				ew32(ITR, 1000000000 / (new_itr * 256));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2509
			else
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2510
				ew32(ITR, 0);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2511
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2512
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2513
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2514
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2515
 * e1000e_write_itr - write the ITR value to the appropriate registers
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2516
 * @adapter: address of board private structure
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2517
 * @itr: new ITR value to program
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2518
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2519
 * e1000e_write_itr determines if the adapter is in MSI-X mode
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2520
 * and, if so, writes the EITR registers with the ITR value.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2521
 * Otherwise, it writes the ITR value into the ITR register.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2522
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2523
void e1000e_write_itr(struct e1000_adapter *adapter, u32 itr)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2524
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2525
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2526
	u32 new_itr = itr ? 1000000000 / (itr * 256) : 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2527
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2528
	if (adapter->msix_entries) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2529
		int vector;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2530
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2531
		for (vector = 0; vector < adapter->num_vectors; vector++)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2532
			writel(new_itr, hw->hw_addr + E1000_EITR_82574(vector));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2533
	} else {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2534
		ew32(ITR, new_itr);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2535
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2536
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2537
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2538
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2539
 * e1000_alloc_queues - Allocate memory for all rings
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2540
 * @adapter: board private structure to initialize
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2541
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2542
static int e1000_alloc_queues(struct e1000_adapter *adapter)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2543
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2544
	int size = sizeof(struct e1000_ring);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2545
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2546
	adapter->tx_ring = kzalloc(size, GFP_KERNEL);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2547
	if (!adapter->tx_ring)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2548
		goto err;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2549
	adapter->tx_ring->count = adapter->tx_ring_count;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2550
	adapter->tx_ring->adapter = adapter;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2551
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2552
	adapter->rx_ring = kzalloc(size, GFP_KERNEL);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2553
	if (!adapter->rx_ring)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2554
		goto err;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2555
	adapter->rx_ring->count = adapter->rx_ring_count;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2556
	adapter->rx_ring->adapter = adapter;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2557
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2558
	return 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2559
err:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2560
	e_err("Unable to allocate memory for queues\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2561
	kfree(adapter->rx_ring);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2562
	kfree(adapter->tx_ring);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2563
	return -ENOMEM;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2564
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2565
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2566
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2567
 * e1000e_poll - NAPI Rx polling callback
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2568
 * @napi: struct associated with this polling callback
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2569
 * @weight: number of packets driver is allowed to process this poll
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2570
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2571
static int e1000e_poll(struct napi_struct *napi, int weight)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2572
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2573
	struct e1000_adapter *adapter = container_of(napi, struct e1000_adapter,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2574
						     napi);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2575
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2576
	struct net_device *poll_dev = adapter->netdev;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2577
	int tx_cleaned = 1, work_done = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2578
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2579
	adapter = netdev_priv(poll_dev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2580
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2581
	if (!adapter->msix_entries ||
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2582
	    (adapter->rx_ring->ims_val & adapter->tx_ring->ims_val))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2583
		tx_cleaned = e1000_clean_tx_irq(adapter->tx_ring);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2584
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2585
	adapter->clean_rx(adapter->rx_ring, &work_done, weight);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2586
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2587
	if (!tx_cleaned)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2588
		work_done = weight;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2589
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2590
	/* If weight not fully consumed, exit the polling mode */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2591
	if (work_done < weight) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2592
		if (adapter->itr_setting & 3)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2593
			e1000_set_itr(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2594
		napi_complete(napi);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2595
		if (!test_bit(__E1000_DOWN, &adapter->state)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2596
			if (adapter->msix_entries)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2597
				ew32(IMS, adapter->rx_ring->ims_val);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2598
			else
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2599
				e1000_irq_enable(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2600
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2601
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2602
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2603
	return work_done;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2604
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2605
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2606
static int e1000_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2607
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2608
	struct e1000_adapter *adapter = netdev_priv(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2609
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2610
	u32 vfta, index;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2611
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2612
	/* don't update vlan cookie if already programmed */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2613
	if ((adapter->hw.mng_cookie.status &
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2614
	     E1000_MNG_DHCP_COOKIE_STATUS_VLAN) &&
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2615
	    (vid == adapter->mng_vlan_id))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2616
		return 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2617
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2618
	/* add VID to filter table */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2619
	if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2620
		index = (vid >> 5) & 0x7F;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2621
		vfta = E1000_READ_REG_ARRAY(hw, E1000_VFTA, index);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2622
		vfta |= (1 << (vid & 0x1F));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2623
		hw->mac.ops.write_vfta(hw, index, vfta);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2624
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2625
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2626
	set_bit(vid, adapter->active_vlans);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2627
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2628
	return 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2629
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2630
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2631
static int e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2632
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2633
	struct e1000_adapter *adapter = netdev_priv(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2634
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2635
	u32 vfta, index;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2636
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2637
	if ((adapter->hw.mng_cookie.status &
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2638
	     E1000_MNG_DHCP_COOKIE_STATUS_VLAN) &&
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2639
	    (vid == adapter->mng_vlan_id)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2640
		/* release control to f/w */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2641
		e1000e_release_hw_control(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2642
		return 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2643
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2644
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2645
	/* remove VID from filter table */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2646
	if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2647
		index = (vid >> 5) & 0x7F;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2648
		vfta = E1000_READ_REG_ARRAY(hw, E1000_VFTA, index);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2649
		vfta &= ~(1 << (vid & 0x1F));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2650
		hw->mac.ops.write_vfta(hw, index, vfta);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2651
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2652
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2653
	clear_bit(vid, adapter->active_vlans);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2654
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2655
	return 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2656
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2657
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2658
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2659
 * e1000e_vlan_filter_disable - helper to disable hw VLAN filtering
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2660
 * @adapter: board private structure to initialize
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2661
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2662
static void e1000e_vlan_filter_disable(struct e1000_adapter *adapter)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2663
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2664
	struct net_device *netdev = adapter->netdev;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2665
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2666
	u32 rctl;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2667
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2668
	if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2669
		/* disable VLAN receive filtering */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2670
		rctl = er32(RCTL);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2671
		rctl &= ~(E1000_RCTL_VFE | E1000_RCTL_CFIEN);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2672
		ew32(RCTL, rctl);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2673
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2674
		if (adapter->mng_vlan_id != (u16)E1000_MNG_VLAN_NONE) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2675
			e1000_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2676
			adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2677
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2678
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2679
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2680
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2681
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2682
 * e1000e_vlan_filter_enable - helper to enable HW VLAN filtering
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2683
 * @adapter: board private structure to initialize
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2684
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2685
static void e1000e_vlan_filter_enable(struct e1000_adapter *adapter)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2686
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2687
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2688
	u32 rctl;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2689
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2690
	if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2691
		/* enable VLAN receive filtering */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2692
		rctl = er32(RCTL);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2693
		rctl |= E1000_RCTL_VFE;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2694
		rctl &= ~E1000_RCTL_CFIEN;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2695
		ew32(RCTL, rctl);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2696
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2697
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2698
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2699
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2700
 * e1000e_vlan_strip_enable - helper to disable HW VLAN stripping
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2701
 * @adapter: board private structure to initialize
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2702
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2703
static void e1000e_vlan_strip_disable(struct e1000_adapter *adapter)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2704
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2705
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2706
	u32 ctrl;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2707
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2708
	/* disable VLAN tag insert/strip */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2709
	ctrl = er32(CTRL);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2710
	ctrl &= ~E1000_CTRL_VME;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2711
	ew32(CTRL, ctrl);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2712
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2713
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2714
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2715
 * e1000e_vlan_strip_enable - helper to enable HW VLAN stripping
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2716
 * @adapter: board private structure to initialize
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2717
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2718
static void e1000e_vlan_strip_enable(struct e1000_adapter *adapter)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2719
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2720
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2721
	u32 ctrl;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2722
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2723
	/* enable VLAN tag insert/strip */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2724
	ctrl = er32(CTRL);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2725
	ctrl |= E1000_CTRL_VME;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2726
	ew32(CTRL, ctrl);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2727
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2728
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2729
static void e1000_update_mng_vlan(struct e1000_adapter *adapter)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2730
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2731
	struct net_device *netdev = adapter->netdev;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2732
	u16 vid = adapter->hw.mng_cookie.vlan_id;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2733
	u16 old_vid = adapter->mng_vlan_id;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2734
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2735
	if (adapter->hw.mng_cookie.status &
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2736
	    E1000_MNG_DHCP_COOKIE_STATUS_VLAN) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2737
		e1000_vlan_rx_add_vid(netdev, vid);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2738
		adapter->mng_vlan_id = vid;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2739
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2740
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2741
	if ((old_vid != (u16)E1000_MNG_VLAN_NONE) && (vid != old_vid))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2742
		e1000_vlan_rx_kill_vid(netdev, old_vid);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2743
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2744
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2745
static void e1000_restore_vlan(struct e1000_adapter *adapter)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2746
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2747
	u16 vid;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2748
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2749
	e1000_vlan_rx_add_vid(adapter->netdev, 0);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2750
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2751
	for_each_set_bit(vid, adapter->active_vlans, VLAN_N_VID)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2752
		e1000_vlan_rx_add_vid(adapter->netdev, vid);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2753
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2754
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2755
static void e1000_init_manageability_pt(struct e1000_adapter *adapter)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2756
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2757
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2758
	u32 manc, manc2h, mdef, i, j;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2759
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2760
	if (!(adapter->flags & FLAG_MNG_PT_ENABLED))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2761
		return;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2762
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2763
	manc = er32(MANC);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2764
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2765
	/* enable receiving management packets to the host. this will probably
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2766
	 * generate destination unreachable messages from the host OS, but
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2767
	 * the packets will be handled on SMBUS
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2768
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2769
	manc |= E1000_MANC_EN_MNG2HOST;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2770
	manc2h = er32(MANC2H);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2771
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2772
	switch (hw->mac.type) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2773
	default:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2774
		manc2h |= (E1000_MANC2H_PORT_623 | E1000_MANC2H_PORT_664);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2775
		break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2776
	case e1000_82574:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2777
	case e1000_82583:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2778
		/* Check if IPMI pass-through decision filter already exists;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2779
		 * if so, enable it.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2780
		 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2781
		for (i = 0, j = 0; i < 8; i++) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2782
			mdef = er32(MDEF(i));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2783
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2784
			/* Ignore filters with anything other than IPMI ports */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2785
			if (mdef & ~(E1000_MDEF_PORT_623 | E1000_MDEF_PORT_664))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2786
				continue;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2787
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2788
			/* Enable this decision filter in MANC2H */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2789
			if (mdef)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2790
				manc2h |= (1 << i);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2791
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2792
			j |= mdef;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2793
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2794
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2795
		if (j == (E1000_MDEF_PORT_623 | E1000_MDEF_PORT_664))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2796
			break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2797
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2798
		/* Create new decision filter in an empty filter */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2799
		for (i = 0, j = 0; i < 8; i++)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2800
			if (er32(MDEF(i)) == 0) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2801
				ew32(MDEF(i), (E1000_MDEF_PORT_623 |
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2802
					       E1000_MDEF_PORT_664));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2803
				manc2h |= (1 << 1);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2804
				j++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2805
				break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2806
			}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2807
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2808
		if (!j)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2809
			e_warn("Unable to create IPMI pass-through filter\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2810
		break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2811
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2812
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2813
	ew32(MANC2H, manc2h);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2814
	ew32(MANC, manc);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2815
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2816
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2817
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2818
 * e1000_configure_tx - Configure Transmit Unit after Reset
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2819
 * @adapter: board private structure
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2820
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2821
 * Configure the Tx unit of the MAC after a reset.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2822
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2823
static void e1000_configure_tx(struct e1000_adapter *adapter)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2824
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2825
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2826
	struct e1000_ring *tx_ring = adapter->tx_ring;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2827
	u64 tdba;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2828
	u32 tdlen, tarc;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2829
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2830
	/* Setup the HW Tx Head and Tail descriptor pointers */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2831
	tdba = tx_ring->dma;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2832
	tdlen = tx_ring->count * sizeof(struct e1000_tx_desc);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2833
	ew32(TDBAL(0), (tdba & DMA_BIT_MASK(32)));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2834
	ew32(TDBAH(0), (tdba >> 32));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2835
	ew32(TDLEN(0), tdlen);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2836
	ew32(TDH(0), 0);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2837
	ew32(TDT(0), 0);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2838
	tx_ring->head = adapter->hw.hw_addr + E1000_TDH(0);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2839
	tx_ring->tail = adapter->hw.hw_addr + E1000_TDT(0);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2840
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2841
	/* Set the Tx Interrupt Delay register */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2842
	ew32(TIDV, adapter->tx_int_delay);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2843
	/* Tx irq moderation */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2844
	ew32(TADV, adapter->tx_abs_int_delay);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2845
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2846
	if (adapter->flags2 & FLAG2_DMA_BURST) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2847
		u32 txdctl = er32(TXDCTL(0));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2848
		txdctl &= ~(E1000_TXDCTL_PTHRESH | E1000_TXDCTL_HTHRESH |
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2849
			    E1000_TXDCTL_WTHRESH);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2850
		/* set up some performance related parameters to encourage the
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2851
		 * hardware to use the bus more efficiently in bursts, depends
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2852
		 * on the tx_int_delay to be enabled,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2853
		 * wthresh = 1 ==> burst write is disabled to avoid Tx stalls
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2854
		 * hthresh = 1 ==> prefetch when one or more available
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2855
		 * pthresh = 0x1f ==> prefetch if internal cache 31 or less
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2856
		 * BEWARE: this seems to work but should be considered first if
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2857
		 * there are Tx hangs or other Tx related bugs
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2858
		 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2859
		txdctl |= E1000_TXDCTL_DMA_BURST_ENABLE;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2860
		ew32(TXDCTL(0), txdctl);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2861
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2862
	/* erratum work around: set txdctl the same for both queues */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2863
	ew32(TXDCTL(1), er32(TXDCTL(0)));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2864
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2865
	if (adapter->flags & FLAG_TARC_SPEED_MODE_BIT) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2866
		tarc = er32(TARC(0));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2867
		/* set the speed mode bit, we'll clear it if we're not at
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2868
		 * gigabit link later
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2869
		 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2870
#define SPEED_MODE_BIT (1 << 21)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2871
		tarc |= SPEED_MODE_BIT;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2872
		ew32(TARC(0), tarc);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2873
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2874
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2875
	/* errata: program both queues to unweighted RR */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2876
	if (adapter->flags & FLAG_TARC_SET_BIT_ZERO) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2877
		tarc = er32(TARC(0));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2878
		tarc |= 1;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2879
		ew32(TARC(0), tarc);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2880
		tarc = er32(TARC(1));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2881
		tarc |= 1;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2882
		ew32(TARC(1), tarc);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2883
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2884
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2885
	/* Setup Transmit Descriptor Settings for eop descriptor */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2886
	adapter->txd_cmd = E1000_TXD_CMD_EOP | E1000_TXD_CMD_IFCS;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2887
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2888
	/* only set IDE if we are delaying interrupts using the timers */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2889
	if (adapter->tx_int_delay)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2890
		adapter->txd_cmd |= E1000_TXD_CMD_IDE;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2891
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2892
	/* enable Report Status bit */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2893
	adapter->txd_cmd |= E1000_TXD_CMD_RS;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2894
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2895
	hw->mac.ops.config_collision_dist(hw);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2896
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2897
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2898
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2899
 * e1000_setup_rctl - configure the receive control registers
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2900
 * @adapter: Board private structure
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2901
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2902
#define PAGE_USE_COUNT(S) (((S) >> PAGE_SHIFT) + \
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2903
			   (((S) & (PAGE_SIZE - 1)) ? 1 : 0))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2904
static void e1000_setup_rctl(struct e1000_adapter *adapter)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2905
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2906
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2907
	u32 rctl, rfctl;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2908
	u32 pages = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2909
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2910
	/* Workaround Si errata on PCHx - configure jumbo frame flow */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2911
	if (hw->mac.type >= e1000_pch2lan) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2912
		s32 ret_val;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2913
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2914
		if (adapter->netdev->mtu > ETH_DATA_LEN)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2915
			ret_val = e1000_lv_jumbo_workaround_ich8lan(hw, true);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2916
		else
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2917
			ret_val = e1000_lv_jumbo_workaround_ich8lan(hw, false);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2918
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2919
		if (ret_val)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2920
			e_dbg("failed to enable jumbo frame workaround mode\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2921
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2922
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2923
	/* Program MC offset vector base */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2924
	rctl = er32(RCTL);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2925
	rctl &= ~(3 << E1000_RCTL_MO_SHIFT);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2926
	rctl |= E1000_RCTL_EN | E1000_RCTL_BAM |
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2927
		E1000_RCTL_LBM_NO | E1000_RCTL_RDMTS_HALF |
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2928
		(adapter->hw.mac.mc_filter_type << E1000_RCTL_MO_SHIFT);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2929
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2930
	/* Do not Store bad packets */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2931
	rctl &= ~E1000_RCTL_SBP;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2932
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2933
	/* Enable Long Packet receive */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2934
	if (adapter->netdev->mtu <= ETH_DATA_LEN)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2935
		rctl &= ~E1000_RCTL_LPE;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2936
	else
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2937
		rctl |= E1000_RCTL_LPE;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2938
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2939
	/* Some systems expect that the CRC is included in SMBUS traffic. The
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2940
	 * hardware strips the CRC before sending to both SMBUS (BMC) and to
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2941
	 * host memory when this is enabled
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2942
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2943
	if (adapter->flags2 & FLAG2_CRC_STRIPPING)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2944
		rctl |= E1000_RCTL_SECRC;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2945
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2946
	/* Workaround Si errata on 82577 PHY - configure IPG for jumbos */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2947
	if ((hw->phy.type == e1000_phy_82577) && (rctl & E1000_RCTL_LPE)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2948
		u16 phy_data;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2949
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2950
		e1e_rphy(hw, PHY_REG(770, 26), &phy_data);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2951
		phy_data &= 0xfff8;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2952
		phy_data |= (1 << 2);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2953
		e1e_wphy(hw, PHY_REG(770, 26), phy_data);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2954
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2955
		e1e_rphy(hw, 22, &phy_data);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2956
		phy_data &= 0x0fff;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2957
		phy_data |= (1 << 14);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2958
		e1e_wphy(hw, 0x10, 0x2823);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2959
		e1e_wphy(hw, 0x11, 0x0003);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2960
		e1e_wphy(hw, 22, phy_data);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2961
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2962
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2963
	/* Setup buffer sizes */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2964
	rctl &= ~E1000_RCTL_SZ_4096;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2965
	rctl |= E1000_RCTL_BSEX;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2966
	switch (adapter->rx_buffer_len) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2967
	case 2048:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2968
	default:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2969
		rctl |= E1000_RCTL_SZ_2048;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2970
		rctl &= ~E1000_RCTL_BSEX;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2971
		break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2972
	case 4096:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2973
		rctl |= E1000_RCTL_SZ_4096;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2974
		break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2975
	case 8192:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2976
		rctl |= E1000_RCTL_SZ_8192;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2977
		break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2978
	case 16384:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2979
		rctl |= E1000_RCTL_SZ_16384;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2980
		break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2981
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2982
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2983
	/* Enable Extended Status in all Receive Descriptors */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2984
	rfctl = er32(RFCTL);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2985
	rfctl |= E1000_RFCTL_EXTEN;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2986
	ew32(RFCTL, rfctl);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2987
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2988
	/* 82571 and greater support packet-split where the protocol
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2989
	 * header is placed in skb->data and the packet data is
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2990
	 * placed in pages hanging off of skb_shinfo(skb)->nr_frags.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2991
	 * In the case of a non-split, skb->data is linearly filled,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2992
	 * followed by the page buffers.  Therefore, skb->data is
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2993
	 * sized to hold the largest protocol header.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2994
	 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2995
	 * allocations using alloc_page take too long for regular MTU
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2996
	 * so only enable packet split for jumbo frames
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2997
	 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2998
	 * Using pages when the page size is greater than 16k wastes
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2999
	 * a lot of memory, since we allocate 3 pages at all times
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3000
	 * per packet.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3001
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3002
	pages = PAGE_USE_COUNT(adapter->netdev->mtu);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3003
	if ((pages <= 3) && (PAGE_SIZE <= 16384) && (rctl & E1000_RCTL_LPE))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3004
		adapter->rx_ps_pages = pages;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3005
	else
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3006
		adapter->rx_ps_pages = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3007
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3008
	if (adapter->rx_ps_pages) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3009
		u32 psrctl = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3010
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3011
		/* Enable Packet split descriptors */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3012
		rctl |= E1000_RCTL_DTYP_PS;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3013
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3014
		psrctl |= adapter->rx_ps_bsize0 >>
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3015
			E1000_PSRCTL_BSIZE0_SHIFT;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3016
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3017
		switch (adapter->rx_ps_pages) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3018
		case 3:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3019
			psrctl |= PAGE_SIZE <<
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3020
				E1000_PSRCTL_BSIZE3_SHIFT;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3021
		case 2:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3022
			psrctl |= PAGE_SIZE <<
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3023
				E1000_PSRCTL_BSIZE2_SHIFT;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3024
		case 1:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3025
			psrctl |= PAGE_SIZE >>
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3026
				E1000_PSRCTL_BSIZE1_SHIFT;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3027
			break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3028
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3029
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3030
		ew32(PSRCTL, psrctl);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3031
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3032
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3033
	/* This is useful for sniffing bad packets. */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3034
	if (adapter->netdev->features & NETIF_F_RXALL) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3035
		/* UPE and MPE will be handled by normal PROMISC logic
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3036
		 * in e1000e_set_rx_mode
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3037
		 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3038
		rctl |= (E1000_RCTL_SBP | /* Receive bad packets */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3039
			 E1000_RCTL_BAM | /* RX All Bcast Pkts */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3040
			 E1000_RCTL_PMCF); /* RX All MAC Ctrl Pkts */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3041
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3042
		rctl &= ~(E1000_RCTL_VFE | /* Disable VLAN filter */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3043
			  E1000_RCTL_DPF | /* Allow filtered pause */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3044
			  E1000_RCTL_CFIEN); /* Dis VLAN CFIEN Filter */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3045
		/* Do not mess with E1000_CTRL_VME, it affects transmit as well,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3046
		 * and that breaks VLANs.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3047
		 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3048
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3049
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3050
	ew32(RCTL, rctl);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3051
	/* just started the receive unit, no need to restart */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3052
	adapter->flags &= ~FLAG_RX_RESTART_NOW;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3053
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3054
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3055
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3056
 * e1000_configure_rx - Configure Receive Unit after Reset
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3057
 * @adapter: board private structure
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3058
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3059
 * Configure the Rx unit of the MAC after a reset.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3060
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3061
static void e1000_configure_rx(struct e1000_adapter *adapter)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3062
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3063
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3064
	struct e1000_ring *rx_ring = adapter->rx_ring;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3065
	u64 rdba;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3066
	u32 rdlen, rctl, rxcsum, ctrl_ext;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3067
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3068
	if (adapter->rx_ps_pages) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3069
		/* this is a 32 byte descriptor */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3070
		rdlen = rx_ring->count *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3071
		    sizeof(union e1000_rx_desc_packet_split);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3072
		adapter->clean_rx = e1000_clean_rx_irq_ps;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3073
		adapter->alloc_rx_buf = e1000_alloc_rx_buffers_ps;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3074
	} else if (adapter->netdev->mtu > ETH_FRAME_LEN + ETH_FCS_LEN) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3075
		rdlen = rx_ring->count * sizeof(union e1000_rx_desc_extended);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3076
		adapter->clean_rx = e1000_clean_jumbo_rx_irq;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3077
		adapter->alloc_rx_buf = e1000_alloc_jumbo_rx_buffers;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3078
	} else {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3079
		rdlen = rx_ring->count * sizeof(union e1000_rx_desc_extended);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3080
		adapter->clean_rx = e1000_clean_rx_irq;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3081
		adapter->alloc_rx_buf = e1000_alloc_rx_buffers;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3082
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3083
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3084
	/* disable receives while setting up the descriptors */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3085
	rctl = er32(RCTL);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3086
	if (!(adapter->flags2 & FLAG2_NO_DISABLE_RX))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3087
		ew32(RCTL, rctl & ~E1000_RCTL_EN);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3088
	e1e_flush();
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3089
	usleep_range(10000, 20000);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3090
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3091
	if (adapter->flags2 & FLAG2_DMA_BURST) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3092
		/* set the writeback threshold (only takes effect if the RDTR
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3093
		 * is set). set GRAN=1 and write back up to 0x4 worth, and
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3094
		 * enable prefetching of 0x20 Rx descriptors
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3095
		 * granularity = 01
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3096
		 * wthresh = 04,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3097
		 * hthresh = 04,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3098
		 * pthresh = 0x20
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3099
		 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3100
		ew32(RXDCTL(0), E1000_RXDCTL_DMA_BURST_ENABLE);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3101
		ew32(RXDCTL(1), E1000_RXDCTL_DMA_BURST_ENABLE);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3102
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3103
		/* override the delay timers for enabling bursting, only if
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3104
		 * the value was not set by the user via module options
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3105
		 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3106
		if (adapter->rx_int_delay == DEFAULT_RDTR)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3107
			adapter->rx_int_delay = BURST_RDTR;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3108
		if (adapter->rx_abs_int_delay == DEFAULT_RADV)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3109
			adapter->rx_abs_int_delay = BURST_RADV;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3110
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3111
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3112
	/* set the Receive Delay Timer Register */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3113
	ew32(RDTR, adapter->rx_int_delay);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3114
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3115
	/* irq moderation */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3116
	ew32(RADV, adapter->rx_abs_int_delay);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3117
	if ((adapter->itr_setting != 0) && (adapter->itr != 0))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3118
		e1000e_write_itr(adapter, adapter->itr);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3119
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3120
	ctrl_ext = er32(CTRL_EXT);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3121
	/* Auto-Mask interrupts upon ICR access */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3122
	ctrl_ext |= E1000_CTRL_EXT_IAME;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3123
	ew32(IAM, 0xffffffff);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3124
	ew32(CTRL_EXT, ctrl_ext);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3125
	e1e_flush();
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3126
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3127
	/* Setup the HW Rx Head and Tail Descriptor Pointers and
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3128
	 * the Base and Length of the Rx Descriptor Ring
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3129
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3130
	rdba = rx_ring->dma;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3131
	ew32(RDBAL(0), (rdba & DMA_BIT_MASK(32)));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3132
	ew32(RDBAH(0), (rdba >> 32));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3133
	ew32(RDLEN(0), rdlen);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3134
	ew32(RDH(0), 0);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3135
	ew32(RDT(0), 0);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3136
	rx_ring->head = adapter->hw.hw_addr + E1000_RDH(0);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3137
	rx_ring->tail = adapter->hw.hw_addr + E1000_RDT(0);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3138
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3139
	/* Enable Receive Checksum Offload for TCP and UDP */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3140
	rxcsum = er32(RXCSUM);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3141
	if (adapter->netdev->features & NETIF_F_RXCSUM)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3142
		rxcsum |= E1000_RXCSUM_TUOFL;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3143
	else
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3144
		rxcsum &= ~E1000_RXCSUM_TUOFL;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3145
	ew32(RXCSUM, rxcsum);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3146
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3147
	if (adapter->hw.mac.type == e1000_pch2lan) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3148
		/* With jumbo frames, excessive C-state transition
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3149
		 * latencies result in dropped transactions.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3150
		 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3151
		if (adapter->netdev->mtu > ETH_DATA_LEN) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3152
			u32 rxdctl = er32(RXDCTL(0));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3153
			ew32(RXDCTL(0), rxdctl | 0x3);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3154
			pm_qos_update_request(&adapter->netdev->pm_qos_req, 55);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3155
		} else {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3156
			pm_qos_update_request(&adapter->netdev->pm_qos_req,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3157
					      PM_QOS_DEFAULT_VALUE);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3158
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3159
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3160
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3161
	/* Enable Receives */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3162
	ew32(RCTL, rctl);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3163
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3164
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3165
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3166
 * e1000e_write_mc_addr_list - write multicast addresses to MTA
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3167
 * @netdev: network interface device structure
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3168
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3169
 * Writes multicast address list to the MTA hash table.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3170
 * Returns: -ENOMEM on failure
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3171
 *                0 on no addresses written
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3172
 *                X on writing X addresses to MTA
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3173
 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3174
static int e1000e_write_mc_addr_list(struct net_device *netdev)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3175
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3176
	struct e1000_adapter *adapter = netdev_priv(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3177
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3178
	struct netdev_hw_addr *ha;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3179
	u8 *mta_list;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3180
	int i;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3181
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3182
	if (netdev_mc_empty(netdev)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3183
		/* nothing to program, so clear mc list */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3184
		hw->mac.ops.update_mc_addr_list(hw, NULL, 0);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3185
		return 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3186
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3187
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3188
	mta_list = kzalloc(netdev_mc_count(netdev) * ETH_ALEN, GFP_ATOMIC);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3189
	if (!mta_list)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3190
		return -ENOMEM;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3191
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3192
	/* update_mc_addr_list expects a packed array of only addresses. */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3193
	i = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3194
	netdev_for_each_mc_addr(ha, netdev)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3195
		memcpy(mta_list + (i++ * ETH_ALEN), ha->addr, ETH_ALEN);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3196
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3197
	hw->mac.ops.update_mc_addr_list(hw, mta_list, i);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3198
	kfree(mta_list);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3199
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3200
	return netdev_mc_count(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3201
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3202
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3203
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3204
 * e1000e_write_uc_addr_list - write unicast addresses to RAR table
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3205
 * @netdev: network interface device structure
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3206
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3207
 * Writes unicast address list to the RAR table.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3208
 * Returns: -ENOMEM on failure/insufficient address space
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3209
 *                0 on no addresses written
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3210
 *                X on writing X addresses to the RAR table
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3211
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3212
static int e1000e_write_uc_addr_list(struct net_device *netdev)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3213
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3214
	struct e1000_adapter *adapter = netdev_priv(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3215
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3216
	unsigned int rar_entries = hw->mac.rar_entry_count;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3217
	int count = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3218
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3219
	/* save a rar entry for our hardware address */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3220
	rar_entries--;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3221
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3222
	/* save a rar entry for the LAA workaround */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3223
	if (adapter->flags & FLAG_RESET_OVERWRITES_LAA)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3224
		rar_entries--;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3225
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3226
	/* return ENOMEM indicating insufficient memory for addresses */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3227
	if (netdev_uc_count(netdev) > rar_entries)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3228
		return -ENOMEM;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3229
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3230
	if (!netdev_uc_empty(netdev) && rar_entries) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3231
		struct netdev_hw_addr *ha;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3232
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3233
		/* write the addresses in reverse order to avoid write
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3234
		 * combining
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3235
		 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3236
		netdev_for_each_uc_addr(ha, netdev) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3237
			if (!rar_entries)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3238
				break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3239
			hw->mac.ops.rar_set(hw, ha->addr, rar_entries--);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3240
			count++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3241
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3242
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3243
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3244
	/* zero out the remaining RAR entries not used above */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3245
	for (; rar_entries > 0; rar_entries--) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3246
		ew32(RAH(rar_entries), 0);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3247
		ew32(RAL(rar_entries), 0);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3248
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3249
	e1e_flush();
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3250
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3251
	return count;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3252
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3253
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3254
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3255
 * e1000e_set_rx_mode - secondary unicast, Multicast and Promiscuous mode set
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3256
 * @netdev: network interface device structure
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3257
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3258
 * The ndo_set_rx_mode entry point is called whenever the unicast or multicast
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3259
 * address list or the network interface flags are updated.  This routine is
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3260
 * responsible for configuring the hardware for proper unicast, multicast,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3261
 * promiscuous mode, and all-multi behavior.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3262
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3263
static void e1000e_set_rx_mode(struct net_device *netdev)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3264
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3265
	struct e1000_adapter *adapter = netdev_priv(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3266
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3267
	u32 rctl;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3268
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3269
	/* Check for Promiscuous and All Multicast modes */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3270
	rctl = er32(RCTL);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3271
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3272
	/* clear the affected bits */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3273
	rctl &= ~(E1000_RCTL_UPE | E1000_RCTL_MPE);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3274
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3275
	if (netdev->flags & IFF_PROMISC) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3276
		rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3277
		/* Do not hardware filter VLANs in promisc mode */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3278
		e1000e_vlan_filter_disable(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3279
	} else {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3280
		int count;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3281
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3282
		if (netdev->flags & IFF_ALLMULTI) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3283
			rctl |= E1000_RCTL_MPE;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3284
		} else {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3285
			/* Write addresses to the MTA, if the attempt fails
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3286
			 * then we should just turn on promiscuous mode so
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3287
			 * that we can at least receive multicast traffic
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3288
			 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3289
			count = e1000e_write_mc_addr_list(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3290
			if (count < 0)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3291
				rctl |= E1000_RCTL_MPE;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3292
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3293
		e1000e_vlan_filter_enable(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3294
		/* Write addresses to available RAR registers, if there is not
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3295
		 * sufficient space to store all the addresses then enable
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3296
		 * unicast promiscuous mode
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3297
		 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3298
		count = e1000e_write_uc_addr_list(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3299
		if (count < 0)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3300
			rctl |= E1000_RCTL_UPE;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3301
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3302
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3303
	ew32(RCTL, rctl);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3304
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3305
	if (netdev->features & NETIF_F_HW_VLAN_RX)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3306
		e1000e_vlan_strip_enable(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3307
	else
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3308
		e1000e_vlan_strip_disable(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3309
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3310
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3311
static void e1000e_setup_rss_hash(struct e1000_adapter *adapter)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3312
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3313
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3314
	u32 mrqc, rxcsum;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3315
	int i;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3316
	static const u32 rsskey[10] = {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3317
		0xda565a6d, 0xc20e5b25, 0x3d256741, 0xb08fa343, 0xcb2bcad0,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3318
		0xb4307bae, 0xa32dcb77, 0x0cf23080, 0x3bb7426a, 0xfa01acbe
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3319
	};
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3320
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3321
	/* Fill out hash function seed */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3322
	for (i = 0; i < 10; i++)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3323
		ew32(RSSRK(i), rsskey[i]);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3324
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3325
	/* Direct all traffic to queue 0 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3326
	for (i = 0; i < 32; i++)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3327
		ew32(RETA(i), 0);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3328
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3329
	/* Disable raw packet checksumming so that RSS hash is placed in
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3330
	 * descriptor on writeback.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3331
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3332
	rxcsum = er32(RXCSUM);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3333
	rxcsum |= E1000_RXCSUM_PCSD;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3334
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3335
	ew32(RXCSUM, rxcsum);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3336
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3337
	mrqc = (E1000_MRQC_RSS_FIELD_IPV4 |
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3338
		E1000_MRQC_RSS_FIELD_IPV4_TCP |
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3339
		E1000_MRQC_RSS_FIELD_IPV6 |
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3340
		E1000_MRQC_RSS_FIELD_IPV6_TCP |
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3341
		E1000_MRQC_RSS_FIELD_IPV6_TCP_EX);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3342
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3343
	ew32(MRQC, mrqc);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3344
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3345
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3346
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3347
 * e1000_configure - configure the hardware for Rx and Tx
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3348
 * @adapter: private board structure
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3349
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3350
static void e1000_configure(struct e1000_adapter *adapter)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3351
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3352
	struct e1000_ring *rx_ring = adapter->rx_ring;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3353
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3354
	e1000e_set_rx_mode(adapter->netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3355
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3356
	e1000_restore_vlan(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3357
	e1000_init_manageability_pt(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3358
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3359
	e1000_configure_tx(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3360
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3361
	if (adapter->netdev->features & NETIF_F_RXHASH)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3362
		e1000e_setup_rss_hash(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3363
	e1000_setup_rctl(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3364
	e1000_configure_rx(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3365
	adapter->alloc_rx_buf(rx_ring, e1000_desc_unused(rx_ring), GFP_KERNEL);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3366
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3367
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3368
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3369
 * e1000e_power_up_phy - restore link in case the phy was powered down
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3370
 * @adapter: address of board private structure
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3371
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3372
 * The phy may be powered down to save power and turn off link when the
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3373
 * driver is unloaded and wake on lan is not enabled (among others)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3374
 * *** this routine MUST be followed by a call to e1000e_reset ***
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3375
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3376
void e1000e_power_up_phy(struct e1000_adapter *adapter)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3377
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3378
	if (adapter->hw.phy.ops.power_up)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3379
		adapter->hw.phy.ops.power_up(&adapter->hw);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3380
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3381
	adapter->hw.mac.ops.setup_link(&adapter->hw);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3382
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3383
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3384
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3385
 * e1000_power_down_phy - Power down the PHY
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3386
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3387
 * Power down the PHY so no link is implied when interface is down.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3388
 * The PHY cannot be powered down if management or WoL is active.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3389
 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3390
static void e1000_power_down_phy(struct e1000_adapter *adapter)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3391
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3392
	/* WoL is enabled */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3393
	if (adapter->wol)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3394
		return;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3395
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3396
	if (adapter->hw.phy.ops.power_down)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3397
		adapter->hw.phy.ops.power_down(&adapter->hw);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3398
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3399
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3400
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3401
 * e1000e_reset - bring the hardware into a known good state
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3402
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3403
 * This function boots the hardware and enables some settings that
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3404
 * require a configuration cycle of the hardware - those cannot be
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3405
 * set/changed during runtime. After reset the device needs to be
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3406
 * properly configured for Rx, Tx etc.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3407
 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3408
void e1000e_reset(struct e1000_adapter *adapter)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3409
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3410
	struct e1000_mac_info *mac = &adapter->hw.mac;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3411
	struct e1000_fc_info *fc = &adapter->hw.fc;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3412
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3413
	u32 tx_space, min_tx_space, min_rx_space;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3414
	u32 pba = adapter->pba;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3415
	u16 hwm;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3416
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3417
	/* reset Packet Buffer Allocation to default */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3418
	ew32(PBA, pba);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3419
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3420
	if (adapter->max_frame_size > ETH_FRAME_LEN + ETH_FCS_LEN) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3421
		/* To maintain wire speed transmits, the Tx FIFO should be
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3422
		 * large enough to accommodate two full transmit packets,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3423
		 * rounded up to the next 1KB and expressed in KB.  Likewise,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3424
		 * the Rx FIFO should be large enough to accommodate at least
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3425
		 * one full receive packet and is similarly rounded up and
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3426
		 * expressed in KB.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3427
		 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3428
		pba = er32(PBA);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3429
		/* upper 16 bits has Tx packet buffer allocation size in KB */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3430
		tx_space = pba >> 16;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3431
		/* lower 16 bits has Rx packet buffer allocation size in KB */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3432
		pba &= 0xffff;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3433
		/* the Tx fifo also stores 16 bytes of information about the Tx
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3434
		 * but don't include ethernet FCS because hardware appends it
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3435
		 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3436
		min_tx_space = (adapter->max_frame_size +
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3437
				sizeof(struct e1000_tx_desc) -
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3438
				ETH_FCS_LEN) * 2;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3439
		min_tx_space = ALIGN(min_tx_space, 1024);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3440
		min_tx_space >>= 10;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3441
		/* software strips receive CRC, so leave room for it */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3442
		min_rx_space = adapter->max_frame_size;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3443
		min_rx_space = ALIGN(min_rx_space, 1024);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3444
		min_rx_space >>= 10;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3445
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3446
		/* If current Tx allocation is less than the min Tx FIFO size,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3447
		 * and the min Tx FIFO size is less than the current Rx FIFO
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3448
		 * allocation, take space away from current Rx allocation
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3449
		 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3450
		if ((tx_space < min_tx_space) &&
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3451
		    ((min_tx_space - tx_space) < pba)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3452
			pba -= min_tx_space - tx_space;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3453
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3454
			/* if short on Rx space, Rx wins and must trump Tx
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3455
			 * adjustment
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3456
			 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3457
			if (pba < min_rx_space)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3458
				pba = min_rx_space;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3459
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3460
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3461
		ew32(PBA, pba);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3462
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3463
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3464
	/* flow control settings
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3465
	 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3466
	 * The high water mark must be low enough to fit one full frame
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3467
	 * (or the size used for early receive) above it in the Rx FIFO.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3468
	 * Set it to the lower of:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3469
	 * - 90% of the Rx FIFO size, and
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3470
	 * - the full Rx FIFO size minus one full frame
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3471
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3472
	if (adapter->flags & FLAG_DISABLE_FC_PAUSE_TIME)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3473
		fc->pause_time = 0xFFFF;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3474
	else
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3475
		fc->pause_time = E1000_FC_PAUSE_TIME;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3476
	fc->send_xon = true;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3477
	fc->current_mode = fc->requested_mode;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3478
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3479
	switch (hw->mac.type) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3480
	case e1000_ich9lan:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3481
	case e1000_ich10lan:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3482
		if (adapter->netdev->mtu > ETH_DATA_LEN) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3483
			pba = 14;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3484
			ew32(PBA, pba);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3485
			fc->high_water = 0x2800;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3486
			fc->low_water = fc->high_water - 8;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3487
			break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3488
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3489
		/* fall-through */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3490
	default:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3491
		hwm = min(((pba << 10) * 9 / 10),
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3492
			  ((pba << 10) - adapter->max_frame_size));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3493
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3494
		fc->high_water = hwm & E1000_FCRTH_RTH; /* 8-byte granularity */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3495
		fc->low_water = fc->high_water - 8;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3496
		break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3497
	case e1000_pchlan:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3498
		/* Workaround PCH LOM adapter hangs with certain network
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3499
		 * loads.  If hangs persist, try disabling Tx flow control.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3500
		 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3501
		if (adapter->netdev->mtu > ETH_DATA_LEN) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3502
			fc->high_water = 0x3500;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3503
			fc->low_water  = 0x1500;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3504
		} else {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3505
			fc->high_water = 0x5000;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3506
			fc->low_water  = 0x3000;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3507
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3508
		fc->refresh_time = 0x1000;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3509
		break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3510
	case e1000_pch2lan:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3511
	case e1000_pch_lpt:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3512
		fc->high_water = 0x05C20;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3513
		fc->low_water = 0x05048;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3514
		fc->pause_time = 0x0650;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3515
		fc->refresh_time = 0x0400;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3516
		if (adapter->netdev->mtu > ETH_DATA_LEN) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3517
			pba = 14;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3518
			ew32(PBA, pba);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3519
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3520
		break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3521
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3522
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3523
	/* Alignment of Tx data is on an arbitrary byte boundary with the
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3524
	 * maximum size per Tx descriptor limited only to the transmit
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3525
	 * allocation of the packet buffer minus 96 bytes with an upper
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3526
	 * limit of 24KB due to receive synchronization limitations.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3527
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3528
	adapter->tx_fifo_limit = min_t(u32, ((er32(PBA) >> 16) << 10) - 96,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3529
				       24 << 10);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3530
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3531
	/* Disable Adaptive Interrupt Moderation if 2 full packets cannot
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3532
	 * fit in receive buffer.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3533
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3534
	if (adapter->itr_setting & 0x3) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3535
		if ((adapter->max_frame_size * 2) > (pba << 10)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3536
			if (!(adapter->flags2 & FLAG2_DISABLE_AIM)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3537
				dev_info(&adapter->pdev->dev,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3538
					"Interrupt Throttle Rate turned off\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3539
				adapter->flags2 |= FLAG2_DISABLE_AIM;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3540
				e1000e_write_itr(adapter, 0);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3541
			}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3542
		} else if (adapter->flags2 & FLAG2_DISABLE_AIM) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3543
			dev_info(&adapter->pdev->dev,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3544
				 "Interrupt Throttle Rate turned on\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3545
			adapter->flags2 &= ~FLAG2_DISABLE_AIM;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3546
			adapter->itr = 20000;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3547
			e1000e_write_itr(adapter, adapter->itr);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3548
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3549
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3550
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3551
	/* Allow time for pending master requests to run */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3552
	mac->ops.reset_hw(hw);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3553
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3554
	/* For parts with AMT enabled, let the firmware know
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3555
	 * that the network interface is in control
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3556
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3557
	if (adapter->flags & FLAG_HAS_AMT)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3558
		e1000e_get_hw_control(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3559
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3560
	ew32(WUC, 0);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3561
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3562
	if (mac->ops.init_hw(hw))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3563
		e_err("Hardware Error\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3564
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3565
	e1000_update_mng_vlan(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3566
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3567
	/* Enable h/w to recognize an 802.1Q VLAN Ethernet packet */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3568
	ew32(VET, ETH_P_8021Q);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3569
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3570
	e1000e_reset_adaptive(hw);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3571
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3572
	if (!netif_running(adapter->netdev) &&
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3573
	    !test_bit(__E1000_TESTING, &adapter->state)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3574
		e1000_power_down_phy(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3575
		return;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3576
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3577
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3578
	e1000_get_phy_info(hw);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3579
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3580
	if ((adapter->flags & FLAG_HAS_SMART_POWER_DOWN) &&
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3581
	    !(adapter->flags & FLAG_SMART_POWER_DOWN)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3582
		u16 phy_data = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3583
		/* speed up time to link by disabling smart power down, ignore
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3584
		 * the return value of this function because there is nothing
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3585
		 * different we would do if it failed
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3586
		 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3587
		e1e_rphy(hw, IGP02E1000_PHY_POWER_MGMT, &phy_data);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3588
		phy_data &= ~IGP02E1000_PM_SPD;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3589
		e1e_wphy(hw, IGP02E1000_PHY_POWER_MGMT, phy_data);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3590
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3591
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3592
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3593
int e1000e_up(struct e1000_adapter *adapter)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3594
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3595
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3596
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3597
	/* hardware has been reset, we need to reload some things */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3598
	e1000_configure(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3599
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3600
	clear_bit(__E1000_DOWN, &adapter->state);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3601
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3602
	if (adapter->msix_entries)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3603
		e1000_configure_msix(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3604
	e1000_irq_enable(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3605
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3606
	netif_start_queue(adapter->netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3607
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3608
	/* fire a link change interrupt to start the watchdog */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3609
	if (adapter->msix_entries)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3610
		ew32(ICS, E1000_ICS_LSC | E1000_ICR_OTHER);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3611
	else
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3612
		ew32(ICS, E1000_ICS_LSC);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3613
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3614
	return 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3615
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3616
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3617
static void e1000e_flush_descriptors(struct e1000_adapter *adapter)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3618
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3619
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3620
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3621
	if (!(adapter->flags2 & FLAG2_DMA_BURST))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3622
		return;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3623
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3624
	/* flush pending descriptor writebacks to memory */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3625
	ew32(TIDV, adapter->tx_int_delay | E1000_TIDV_FPD);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3626
	ew32(RDTR, adapter->rx_int_delay | E1000_RDTR_FPD);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3627
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3628
	/* execute the writes immediately */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3629
	e1e_flush();
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3630
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3631
	/* due to rare timing issues, write to TIDV/RDTR again to ensure the
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3632
	 * write is successful
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3633
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3634
	ew32(TIDV, adapter->tx_int_delay | E1000_TIDV_FPD);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3635
	ew32(RDTR, adapter->rx_int_delay | E1000_RDTR_FPD);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3636
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3637
	/* execute the writes immediately */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3638
	e1e_flush();
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3639
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3640
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3641
static void e1000e_update_stats(struct e1000_adapter *adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3642
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3643
void e1000e_down(struct e1000_adapter *adapter)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3644
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3645
	struct net_device *netdev = adapter->netdev;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3646
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3647
	u32 tctl, rctl;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3648
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3649
	/* signal that we're down so the interrupt handler does not
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3650
	 * reschedule our watchdog timer
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3651
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3652
	set_bit(__E1000_DOWN, &adapter->state);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3653
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3654
	/* disable receives in the hardware */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3655
	rctl = er32(RCTL);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3656
	if (!(adapter->flags2 & FLAG2_NO_DISABLE_RX))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3657
		ew32(RCTL, rctl & ~E1000_RCTL_EN);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3658
	/* flush and sleep below */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3659
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3660
	netif_stop_queue(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3661
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3662
	/* disable transmits in the hardware */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3663
	tctl = er32(TCTL);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3664
	tctl &= ~E1000_TCTL_EN;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3665
	ew32(TCTL, tctl);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3666
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3667
	/* flush both disables and wait for them to finish */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3668
	e1e_flush();
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3669
	usleep_range(10000, 20000);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3670
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3671
	e1000_irq_disable(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3672
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3673
	del_timer_sync(&adapter->watchdog_timer);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3674
	del_timer_sync(&adapter->phy_info_timer);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3675
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3676
	netif_carrier_off(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3677
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3678
	spin_lock(&adapter->stats64_lock);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3679
	e1000e_update_stats(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3680
	spin_unlock(&adapter->stats64_lock);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3681
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3682
	e1000e_flush_descriptors(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3683
	e1000_clean_tx_ring(adapter->tx_ring);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3684
	e1000_clean_rx_ring(adapter->rx_ring);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3685
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3686
	adapter->link_speed = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3687
	adapter->link_duplex = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3688
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3689
	if (!pci_channel_offline(adapter->pdev))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3690
		e1000e_reset(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3691
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3692
	/* TODO: for power management, we could drop the link and
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3693
	 * pci_disable_device here.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3694
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3695
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3696
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3697
void e1000e_reinit_locked(struct e1000_adapter *adapter)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3698
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3699
	might_sleep();
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3700
	while (test_and_set_bit(__E1000_RESETTING, &adapter->state))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3701
		usleep_range(1000, 2000);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3702
	e1000e_down(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3703
	e1000e_up(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3704
	clear_bit(__E1000_RESETTING, &adapter->state);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3705
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3706
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3707
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3708
 * e1000_sw_init - Initialize general software structures (struct e1000_adapter)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3709
 * @adapter: board private structure to initialize
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3710
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3711
 * e1000_sw_init initializes the Adapter private data structure.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3712
 * Fields are initialized based on PCI device information and
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3713
 * OS network device settings (MTU size).
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3714
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3715
static int e1000_sw_init(struct e1000_adapter *adapter)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3716
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3717
	struct net_device *netdev = adapter->netdev;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3718
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3719
	adapter->rx_buffer_len = ETH_FRAME_LEN + VLAN_HLEN + ETH_FCS_LEN;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3720
	adapter->rx_ps_bsize0 = 128;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3721
	adapter->max_frame_size = netdev->mtu + ETH_HLEN + ETH_FCS_LEN;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3722
	adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3723
	adapter->tx_ring_count = E1000_DEFAULT_TXD;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3724
	adapter->rx_ring_count = E1000_DEFAULT_RXD;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3725
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3726
	spin_lock_init(&adapter->stats64_lock);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3727
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3728
	e1000e_set_interrupt_capability(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3729
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3730
	if (e1000_alloc_queues(adapter))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3731
		return -ENOMEM;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3732
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3733
	/* Explicitly disable IRQ since the NIC can be in any state. */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3734
	e1000_irq_disable(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3735
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3736
	set_bit(__E1000_DOWN, &adapter->state);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3737
	return 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3738
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3739
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3740
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3741
 * e1000_intr_msi_test - Interrupt Handler
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3742
 * @irq: interrupt number
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3743
 * @data: pointer to a network interface device structure
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3744
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3745
static irqreturn_t e1000_intr_msi_test(int irq, void *data)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3746
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3747
	struct net_device *netdev = data;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3748
	struct e1000_adapter *adapter = netdev_priv(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3749
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3750
	u32 icr = er32(ICR);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3751
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3752
	e_dbg("icr is %08X\n", icr);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3753
	if (icr & E1000_ICR_RXSEQ) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3754
		adapter->flags &= ~FLAG_MSI_TEST_FAILED;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3755
		/* Force memory writes to complete before acknowledging the
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3756
		 * interrupt is handled.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3757
		 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3758
		wmb();
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3759
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3760
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3761
	return IRQ_HANDLED;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3762
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3763
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3764
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3765
 * e1000_test_msi_interrupt - Returns 0 for successful test
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3766
 * @adapter: board private struct
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3767
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3768
 * code flow taken from tg3.c
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3769
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3770
static int e1000_test_msi_interrupt(struct e1000_adapter *adapter)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3771
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3772
	struct net_device *netdev = adapter->netdev;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3773
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3774
	int err;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3775
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3776
	/* poll_enable hasn't been called yet, so don't need disable */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3777
	/* clear any pending events */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3778
	er32(ICR);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3779
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3780
	/* free the real vector and request a test handler */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3781
	e1000_free_irq(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3782
	e1000e_reset_interrupt_capability(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3783
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3784
	/* Assume that the test fails, if it succeeds then the test
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3785
	 * MSI irq handler will unset this flag
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3786
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3787
	adapter->flags |= FLAG_MSI_TEST_FAILED;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3788
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3789
	err = pci_enable_msi(adapter->pdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3790
	if (err)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3791
		goto msi_test_failed;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3792
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3793
	err = request_irq(adapter->pdev->irq, e1000_intr_msi_test, 0,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3794
			  netdev->name, netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3795
	if (err) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3796
		pci_disable_msi(adapter->pdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3797
		goto msi_test_failed;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3798
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3799
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3800
	/* Force memory writes to complete before enabling and firing an
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3801
	 * interrupt.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3802
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3803
	wmb();
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3804
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3805
	e1000_irq_enable(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3806
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3807
	/* fire an unusual interrupt on the test handler */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3808
	ew32(ICS, E1000_ICS_RXSEQ);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3809
	e1e_flush();
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3810
	msleep(100);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3811
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3812
	e1000_irq_disable(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3813
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3814
	rmb();			/* read flags after interrupt has been fired */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3815
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3816
	if (adapter->flags & FLAG_MSI_TEST_FAILED) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3817
		adapter->int_mode = E1000E_INT_MODE_LEGACY;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3818
		e_info("MSI interrupt test failed, using legacy interrupt.\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3819
	} else {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3820
		e_dbg("MSI interrupt test succeeded!\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3821
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3822
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3823
	free_irq(adapter->pdev->irq, netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3824
	pci_disable_msi(adapter->pdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3825
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3826
msi_test_failed:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3827
	e1000e_set_interrupt_capability(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3828
	return e1000_request_irq(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3829
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3830
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3831
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3832
 * e1000_test_msi - Returns 0 if MSI test succeeds or INTx mode is restored
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3833
 * @adapter: board private struct
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3834
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3835
 * code flow taken from tg3.c, called with e1000 interrupts disabled.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3836
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3837
static int e1000_test_msi(struct e1000_adapter *adapter)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3838
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3839
	int err;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3840
	u16 pci_cmd;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3841
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3842
	if (!(adapter->flags & FLAG_MSI_ENABLED))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3843
		return 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3844
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3845
	/* disable SERR in case the MSI write causes a master abort */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3846
	pci_read_config_word(adapter->pdev, PCI_COMMAND, &pci_cmd);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3847
	if (pci_cmd & PCI_COMMAND_SERR)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3848
		pci_write_config_word(adapter->pdev, PCI_COMMAND,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3849
				      pci_cmd & ~PCI_COMMAND_SERR);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3850
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3851
	err = e1000_test_msi_interrupt(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3852
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3853
	/* re-enable SERR */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3854
	if (pci_cmd & PCI_COMMAND_SERR) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3855
		pci_read_config_word(adapter->pdev, PCI_COMMAND, &pci_cmd);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3856
		pci_cmd |= PCI_COMMAND_SERR;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3857
		pci_write_config_word(adapter->pdev, PCI_COMMAND, pci_cmd);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3858
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3859
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3860
	return err;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3861
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3862
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3863
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3864
 * e1000_open - Called when a network interface is made active
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3865
 * @netdev: network interface device structure
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3866
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3867
 * Returns 0 on success, negative value on failure
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3868
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3869
 * The open entry point is called when a network interface is made
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3870
 * active by the system (IFF_UP).  At this point all resources needed
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3871
 * for transmit and receive operations are allocated, the interrupt
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3872
 * handler is registered with the OS, the watchdog timer is started,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3873
 * and the stack is notified that the interface is ready.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3874
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3875
static int e1000_open(struct net_device *netdev)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3876
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3877
	struct e1000_adapter *adapter = netdev_priv(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3878
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3879
	struct pci_dev *pdev = adapter->pdev;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3880
	int err;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3881
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3882
	/* disallow open during test */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3883
	if (test_bit(__E1000_TESTING, &adapter->state))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3884
		return -EBUSY;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3885
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3886
	pm_runtime_get_sync(&pdev->dev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3887
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3888
	netif_carrier_off(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3889
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3890
	/* allocate transmit descriptors */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3891
	err = e1000e_setup_tx_resources(adapter->tx_ring);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3892
	if (err)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3893
		goto err_setup_tx;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3894
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3895
	/* allocate receive descriptors */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3896
	err = e1000e_setup_rx_resources(adapter->rx_ring);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3897
	if (err)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3898
		goto err_setup_rx;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3899
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3900
	/* If AMT is enabled, let the firmware know that the network
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3901
	 * interface is now open and reset the part to a known state.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3902
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3903
	if (adapter->flags & FLAG_HAS_AMT) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3904
		e1000e_get_hw_control(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3905
		e1000e_reset(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3906
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3907
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3908
	e1000e_power_up_phy(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3909
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3910
	adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3911
	if ((adapter->hw.mng_cookie.status &
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3912
	     E1000_MNG_DHCP_COOKIE_STATUS_VLAN))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3913
		e1000_update_mng_vlan(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3914
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3915
	/* DMA latency requirement to workaround jumbo issue */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3916
	if (adapter->hw.mac.type == e1000_pch2lan)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3917
		pm_qos_add_request(&adapter->netdev->pm_qos_req,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3918
				   PM_QOS_CPU_DMA_LATENCY,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3919
				   PM_QOS_DEFAULT_VALUE);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3920
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3921
	/* before we allocate an interrupt, we must be ready to handle it.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3922
	 * Setting DEBUG_SHIRQ in the kernel makes it fire an interrupt
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3923
	 * as soon as we call pci_request_irq, so we have to setup our
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3924
	 * clean_rx handler before we do so.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3925
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3926
	e1000_configure(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3927
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3928
	err = e1000_request_irq(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3929
	if (err)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3930
		goto err_req_irq;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3931
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3932
	/* Work around PCIe errata with MSI interrupts causing some chipsets to
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3933
	 * ignore e1000e MSI messages, which means we need to test our MSI
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3934
	 * interrupt now
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3935
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3936
	if (adapter->int_mode != E1000E_INT_MODE_LEGACY) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3937
		err = e1000_test_msi(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3938
		if (err) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3939
			e_err("Interrupt allocation failed\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3940
			goto err_req_irq;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3941
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3942
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3943
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3944
	/* From here on the code is the same as e1000e_up() */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3945
	clear_bit(__E1000_DOWN, &adapter->state);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3946
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3947
	napi_enable(&adapter->napi);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3948
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3949
	e1000_irq_enable(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3950
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3951
	adapter->tx_hang_recheck = false;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3952
	netif_start_queue(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3953
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3954
	adapter->idle_check = true;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3955
	hw->mac.get_link_status = true;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3956
	pm_runtime_put(&pdev->dev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3957
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3958
	/* fire a link status change interrupt to start the watchdog */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3959
	if (adapter->msix_entries)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3960
		ew32(ICS, E1000_ICS_LSC | E1000_ICR_OTHER);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3961
	else
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3962
		ew32(ICS, E1000_ICS_LSC);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3963
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3964
	return 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3965
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3966
err_req_irq:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3967
	e1000e_release_hw_control(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3968
	e1000_power_down_phy(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3969
	e1000e_free_rx_resources(adapter->rx_ring);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3970
err_setup_rx:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3971
	e1000e_free_tx_resources(adapter->tx_ring);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3972
err_setup_tx:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3973
	e1000e_reset(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3974
	pm_runtime_put_sync(&pdev->dev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3975
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3976
	return err;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3977
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3978
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3979
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3980
 * e1000_close - Disables a network interface
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3981
 * @netdev: network interface device structure
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3982
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3983
 * Returns 0, this is not allowed to fail
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3984
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3985
 * The close entry point is called when an interface is de-activated
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3986
 * by the OS.  The hardware is still under the drivers control, but
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3987
 * needs to be disabled.  A global MAC reset is issued to stop the
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3988
 * hardware, and all transmit and receive resources are freed.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3989
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3990
static int e1000_close(struct net_device *netdev)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3991
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3992
	struct e1000_adapter *adapter = netdev_priv(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3993
	struct pci_dev *pdev = adapter->pdev;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3994
	int count = E1000_CHECK_RESET_COUNT;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3995
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3996
	while (test_bit(__E1000_RESETTING, &adapter->state) && count--)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3997
		usleep_range(10000, 20000);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3998
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3999
	WARN_ON(test_bit(__E1000_RESETTING, &adapter->state));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4000
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4001
	pm_runtime_get_sync(&pdev->dev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4002
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4003
	napi_disable(&adapter->napi);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4004
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4005
	if (!test_bit(__E1000_DOWN, &adapter->state)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4006
		e1000e_down(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4007
		e1000_free_irq(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4008
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4009
	e1000_power_down_phy(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4010
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4011
	e1000e_free_tx_resources(adapter->tx_ring);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4012
	e1000e_free_rx_resources(adapter->rx_ring);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4013
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4014
	/* kill manageability vlan ID if supported, but not if a vlan with
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4015
	 * the same ID is registered on the host OS (let 8021q kill it)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4016
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4017
	if (adapter->hw.mng_cookie.status &
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4018
	    E1000_MNG_DHCP_COOKIE_STATUS_VLAN)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4019
		e1000_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4020
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4021
	/* If AMT is enabled, let the firmware know that the network
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4022
	 * interface is now closed
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4023
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4024
	if ((adapter->flags & FLAG_HAS_AMT) &&
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4025
	    !test_bit(__E1000_TESTING, &adapter->state))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4026
		e1000e_release_hw_control(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4027
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4028
	if (adapter->hw.mac.type == e1000_pch2lan)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4029
		pm_qos_remove_request(&adapter->netdev->pm_qos_req);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4030
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4031
	pm_runtime_put_sync(&pdev->dev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4032
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4033
	return 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4034
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4035
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4036
 * e1000_set_mac - Change the Ethernet Address of the NIC
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4037
 * @netdev: network interface device structure
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4038
 * @p: pointer to an address structure
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4039
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4040
 * Returns 0 on success, negative on failure
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4041
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4042
static int e1000_set_mac(struct net_device *netdev, void *p)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4043
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4044
	struct e1000_adapter *adapter = netdev_priv(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4045
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4046
	struct sockaddr *addr = p;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4047
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4048
	if (!is_valid_ether_addr(addr->sa_data))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4049
		return -EADDRNOTAVAIL;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4050
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4051
	memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4052
	memcpy(adapter->hw.mac.addr, addr->sa_data, netdev->addr_len);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4053
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4054
	hw->mac.ops.rar_set(&adapter->hw, adapter->hw.mac.addr, 0);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4055
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4056
	if (adapter->flags & FLAG_RESET_OVERWRITES_LAA) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4057
		/* activate the work around */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4058
		e1000e_set_laa_state_82571(&adapter->hw, 1);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4059
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4060
		/* Hold a copy of the LAA in RAR[14] This is done so that
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4061
		 * between the time RAR[0] gets clobbered  and the time it
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4062
		 * gets fixed (in e1000_watchdog), the actual LAA is in one
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4063
		 * of the RARs and no incoming packets directed to this port
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4064
		 * are dropped. Eventually the LAA will be in RAR[0] and
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4065
		 * RAR[14]
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4066
		 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4067
		hw->mac.ops.rar_set(&adapter->hw, adapter->hw.mac.addr,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4068
				    adapter->hw.mac.rar_entry_count - 1);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4069
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4070
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4071
	return 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4072
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4073
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4074
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4075
 * e1000e_update_phy_task - work thread to update phy
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4076
 * @work: pointer to our work struct
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4077
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4078
 * this worker thread exists because we must acquire a
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4079
 * semaphore to read the phy, which we could msleep while
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4080
 * waiting for it, and we can't msleep in a timer.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4081
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4082
static void e1000e_update_phy_task(struct work_struct *work)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4083
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4084
	struct e1000_adapter *adapter = container_of(work,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4085
					struct e1000_adapter, update_phy_task);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4086
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4087
	if (test_bit(__E1000_DOWN, &adapter->state))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4088
		return;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4089
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4090
	e1000_get_phy_info(&adapter->hw);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4091
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4092
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4093
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4094
 * e1000_update_phy_info - timre call-back to update PHY info
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4095
 * @data: pointer to adapter cast into an unsigned long
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4096
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4097
 * Need to wait a few seconds after link up to get diagnostic information from
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4098
 * the phy
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4099
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4100
static void e1000_update_phy_info(unsigned long data)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4101
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4102
	struct e1000_adapter *adapter = (struct e1000_adapter *) data;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4103
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4104
	if (test_bit(__E1000_DOWN, &adapter->state))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4105
		return;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4106
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4107
	schedule_work(&adapter->update_phy_task);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4108
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4109
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4110
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4111
 * e1000e_update_phy_stats - Update the PHY statistics counters
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4112
 * @adapter: board private structure
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4113
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4114
 * Read/clear the upper 16-bit PHY registers and read/accumulate lower
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4115
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4116
static void e1000e_update_phy_stats(struct e1000_adapter *adapter)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4117
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4118
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4119
	s32 ret_val;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4120
	u16 phy_data;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4121
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4122
	ret_val = hw->phy.ops.acquire(hw);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4123
	if (ret_val)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4124
		return;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4125
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4126
	/* A page set is expensive so check if already on desired page.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4127
	 * If not, set to the page with the PHY status registers.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4128
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4129
	hw->phy.addr = 1;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4130
	ret_val = e1000e_read_phy_reg_mdic(hw, IGP01E1000_PHY_PAGE_SELECT,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4131
					   &phy_data);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4132
	if (ret_val)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4133
		goto release;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4134
	if (phy_data != (HV_STATS_PAGE << IGP_PAGE_SHIFT)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4135
		ret_val = hw->phy.ops.set_page(hw,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4136
					       HV_STATS_PAGE << IGP_PAGE_SHIFT);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4137
		if (ret_val)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4138
			goto release;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4139
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4140
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4141
	/* Single Collision Count */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4142
	hw->phy.ops.read_reg_page(hw, HV_SCC_UPPER, &phy_data);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4143
	ret_val = hw->phy.ops.read_reg_page(hw, HV_SCC_LOWER, &phy_data);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4144
	if (!ret_val)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4145
		adapter->stats.scc += phy_data;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4146
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4147
	/* Excessive Collision Count */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4148
	hw->phy.ops.read_reg_page(hw, HV_ECOL_UPPER, &phy_data);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4149
	ret_val = hw->phy.ops.read_reg_page(hw, HV_ECOL_LOWER, &phy_data);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4150
	if (!ret_val)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4151
		adapter->stats.ecol += phy_data;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4152
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4153
	/* Multiple Collision Count */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4154
	hw->phy.ops.read_reg_page(hw, HV_MCC_UPPER, &phy_data);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4155
	ret_val = hw->phy.ops.read_reg_page(hw, HV_MCC_LOWER, &phy_data);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4156
	if (!ret_val)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4157
		adapter->stats.mcc += phy_data;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4158
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4159
	/* Late Collision Count */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4160
	hw->phy.ops.read_reg_page(hw, HV_LATECOL_UPPER, &phy_data);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4161
	ret_val = hw->phy.ops.read_reg_page(hw, HV_LATECOL_LOWER, &phy_data);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4162
	if (!ret_val)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4163
		adapter->stats.latecol += phy_data;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4164
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4165
	/* Collision Count - also used for adaptive IFS */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4166
	hw->phy.ops.read_reg_page(hw, HV_COLC_UPPER, &phy_data);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4167
	ret_val = hw->phy.ops.read_reg_page(hw, HV_COLC_LOWER, &phy_data);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4168
	if (!ret_val)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4169
		hw->mac.collision_delta = phy_data;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4170
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4171
	/* Defer Count */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4172
	hw->phy.ops.read_reg_page(hw, HV_DC_UPPER, &phy_data);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4173
	ret_val = hw->phy.ops.read_reg_page(hw, HV_DC_LOWER, &phy_data);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4174
	if (!ret_val)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4175
		adapter->stats.dc += phy_data;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4176
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4177
	/* Transmit with no CRS */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4178
	hw->phy.ops.read_reg_page(hw, HV_TNCRS_UPPER, &phy_data);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4179
	ret_val = hw->phy.ops.read_reg_page(hw, HV_TNCRS_LOWER, &phy_data);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4180
	if (!ret_val)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4181
		adapter->stats.tncrs += phy_data;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4182
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4183
release:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4184
	hw->phy.ops.release(hw);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4185
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4186
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4187
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4188
 * e1000e_update_stats - Update the board statistics counters
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4189
 * @adapter: board private structure
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4190
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4191
static void e1000e_update_stats(struct e1000_adapter *adapter)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4192
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4193
	struct net_device *netdev = adapter->netdev;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4194
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4195
	struct pci_dev *pdev = adapter->pdev;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4196
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4197
	/* Prevent stats update while adapter is being reset, or if the pci
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4198
	 * connection is down.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4199
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4200
	if (adapter->link_speed == 0)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4201
		return;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4202
	if (pci_channel_offline(pdev))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4203
		return;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4204
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4205
	adapter->stats.crcerrs += er32(CRCERRS);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4206
	adapter->stats.gprc += er32(GPRC);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4207
	adapter->stats.gorc += er32(GORCL);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4208
	er32(GORCH); /* Clear gorc */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4209
	adapter->stats.bprc += er32(BPRC);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4210
	adapter->stats.mprc += er32(MPRC);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4211
	adapter->stats.roc += er32(ROC);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4212
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4213
	adapter->stats.mpc += er32(MPC);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4214
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4215
	/* Half-duplex statistics */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4216
	if (adapter->link_duplex == HALF_DUPLEX) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4217
		if (adapter->flags2 & FLAG2_HAS_PHY_STATS) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4218
			e1000e_update_phy_stats(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4219
		} else {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4220
			adapter->stats.scc += er32(SCC);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4221
			adapter->stats.ecol += er32(ECOL);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4222
			adapter->stats.mcc += er32(MCC);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4223
			adapter->stats.latecol += er32(LATECOL);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4224
			adapter->stats.dc += er32(DC);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4225
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4226
			hw->mac.collision_delta = er32(COLC);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4227
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4228
			if ((hw->mac.type != e1000_82574) &&
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4229
			    (hw->mac.type != e1000_82583))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4230
				adapter->stats.tncrs += er32(TNCRS);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4231
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4232
		adapter->stats.colc += hw->mac.collision_delta;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4233
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4234
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4235
	adapter->stats.xonrxc += er32(XONRXC);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4236
	adapter->stats.xontxc += er32(XONTXC);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4237
	adapter->stats.xoffrxc += er32(XOFFRXC);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4238
	adapter->stats.xofftxc += er32(XOFFTXC);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4239
	adapter->stats.gptc += er32(GPTC);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4240
	adapter->stats.gotc += er32(GOTCL);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4241
	er32(GOTCH); /* Clear gotc */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4242
	adapter->stats.rnbc += er32(RNBC);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4243
	adapter->stats.ruc += er32(RUC);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4244
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4245
	adapter->stats.mptc += er32(MPTC);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4246
	adapter->stats.bptc += er32(BPTC);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4247
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4248
	/* used for adaptive IFS */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4249
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4250
	hw->mac.tx_packet_delta = er32(TPT);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4251
	adapter->stats.tpt += hw->mac.tx_packet_delta;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4252
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4253
	adapter->stats.algnerrc += er32(ALGNERRC);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4254
	adapter->stats.rxerrc += er32(RXERRC);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4255
	adapter->stats.cexterr += er32(CEXTERR);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4256
	adapter->stats.tsctc += er32(TSCTC);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4257
	adapter->stats.tsctfc += er32(TSCTFC);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4258
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4259
	/* Fill out the OS statistics structure */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4260
	netdev->stats.multicast = adapter->stats.mprc;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4261
	netdev->stats.collisions = adapter->stats.colc;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4262
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4263
	/* Rx Errors */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4264
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4265
	/* RLEC on some newer hardware can be incorrect so build
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4266
	 * our own version based on RUC and ROC
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4267
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4268
	netdev->stats.rx_errors = adapter->stats.rxerrc +
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4269
		adapter->stats.crcerrs + adapter->stats.algnerrc +
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4270
		adapter->stats.ruc + adapter->stats.roc +
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4271
		adapter->stats.cexterr;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4272
	netdev->stats.rx_length_errors = adapter->stats.ruc +
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4273
					      adapter->stats.roc;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4274
	netdev->stats.rx_crc_errors = adapter->stats.crcerrs;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4275
	netdev->stats.rx_frame_errors = adapter->stats.algnerrc;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4276
	netdev->stats.rx_missed_errors = adapter->stats.mpc;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4277
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4278
	/* Tx Errors */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4279
	netdev->stats.tx_errors = adapter->stats.ecol +
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4280
				       adapter->stats.latecol;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4281
	netdev->stats.tx_aborted_errors = adapter->stats.ecol;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4282
	netdev->stats.tx_window_errors = adapter->stats.latecol;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4283
	netdev->stats.tx_carrier_errors = adapter->stats.tncrs;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4284
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4285
	/* Tx Dropped needs to be maintained elsewhere */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4286
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4287
	/* Management Stats */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4288
	adapter->stats.mgptc += er32(MGTPTC);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4289
	adapter->stats.mgprc += er32(MGTPRC);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4290
	adapter->stats.mgpdc += er32(MGTPDC);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4291
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4292
	/* Correctable ECC Errors */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4293
	if (hw->mac.type == e1000_pch_lpt) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4294
		u32 pbeccsts = er32(PBECCSTS);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4295
		adapter->corr_errors +=
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4296
		    pbeccsts & E1000_PBECCSTS_CORR_ERR_CNT_MASK;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4297
		adapter->uncorr_errors +=
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4298
		    (pbeccsts & E1000_PBECCSTS_UNCORR_ERR_CNT_MASK) >>
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4299
		    E1000_PBECCSTS_UNCORR_ERR_CNT_SHIFT;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4300
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4301
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4302
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4303
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4304
 * e1000_phy_read_status - Update the PHY register status snapshot
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4305
 * @adapter: board private structure
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4306
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4307
static void e1000_phy_read_status(struct e1000_adapter *adapter)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4308
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4309
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4310
	struct e1000_phy_regs *phy = &adapter->phy_regs;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4311
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4312
	if ((er32(STATUS) & E1000_STATUS_LU) &&
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4313
	    (adapter->hw.phy.media_type == e1000_media_type_copper)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4314
		int ret_val;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4315
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4316
		pm_runtime_get_sync(&adapter->pdev->dev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4317
		ret_val  = e1e_rphy(hw, PHY_CONTROL, &phy->bmcr);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4318
		ret_val |= e1e_rphy(hw, PHY_STATUS, &phy->bmsr);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4319
		ret_val |= e1e_rphy(hw, PHY_AUTONEG_ADV, &phy->advertise);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4320
		ret_val |= e1e_rphy(hw, PHY_LP_ABILITY, &phy->lpa);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4321
		ret_val |= e1e_rphy(hw, PHY_AUTONEG_EXP, &phy->expansion);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4322
		ret_val |= e1e_rphy(hw, PHY_1000T_CTRL, &phy->ctrl1000);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4323
		ret_val |= e1e_rphy(hw, PHY_1000T_STATUS, &phy->stat1000);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4324
		ret_val |= e1e_rphy(hw, PHY_EXT_STATUS, &phy->estatus);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4325
		if (ret_val)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4326
			e_warn("Error reading PHY register\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4327
		pm_runtime_put_sync(&adapter->pdev->dev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4328
	} else {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4329
		/* Do not read PHY registers if link is not up
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4330
		 * Set values to typical power-on defaults
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4331
		 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4332
		phy->bmcr = (BMCR_SPEED1000 | BMCR_ANENABLE | BMCR_FULLDPLX);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4333
		phy->bmsr = (BMSR_100FULL | BMSR_100HALF | BMSR_10FULL |
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4334
			     BMSR_10HALF | BMSR_ESTATEN | BMSR_ANEGCAPABLE |
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4335
			     BMSR_ERCAP);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4336
		phy->advertise = (ADVERTISE_PAUSE_ASYM | ADVERTISE_PAUSE_CAP |
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4337
				  ADVERTISE_ALL | ADVERTISE_CSMA);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4338
		phy->lpa = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4339
		phy->expansion = EXPANSION_ENABLENPAGE;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4340
		phy->ctrl1000 = ADVERTISE_1000FULL;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4341
		phy->stat1000 = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4342
		phy->estatus = (ESTATUS_1000_TFULL | ESTATUS_1000_THALF);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4343
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4344
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4345
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4346
static void e1000_print_link_info(struct e1000_adapter *adapter)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4347
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4348
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4349
	u32 ctrl = er32(CTRL);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4350
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4351
	/* Link status message must follow this format for user tools */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4352
	printk(KERN_INFO "e1000e: %s NIC Link is Up %d Mbps %s Duplex, Flow Control: %s\n",
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4353
		adapter->netdev->name,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4354
		adapter->link_speed,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4355
		adapter->link_duplex == FULL_DUPLEX ? "Full" : "Half",
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4356
		(ctrl & E1000_CTRL_TFCE) && (ctrl & E1000_CTRL_RFCE) ? "Rx/Tx" :
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4357
		(ctrl & E1000_CTRL_RFCE) ? "Rx" :
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4358
		(ctrl & E1000_CTRL_TFCE) ? "Tx" : "None");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4359
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4360
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4361
static bool e1000e_has_link(struct e1000_adapter *adapter)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4362
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4363
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4364
	bool link_active = false;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4365
	s32 ret_val = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4366
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4367
	/* get_link_status is set on LSC (link status) interrupt or
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4368
	 * Rx sequence error interrupt.  get_link_status will stay
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4369
	 * false until the check_for_link establishes link
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4370
	 * for copper adapters ONLY
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4371
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4372
	switch (hw->phy.media_type) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4373
	case e1000_media_type_copper:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4374
		if (hw->mac.get_link_status) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4375
			ret_val = hw->mac.ops.check_for_link(hw);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4376
			link_active = !hw->mac.get_link_status;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4377
		} else {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4378
			link_active = true;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4379
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4380
		break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4381
	case e1000_media_type_fiber:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4382
		ret_val = hw->mac.ops.check_for_link(hw);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4383
		link_active = !!(er32(STATUS) & E1000_STATUS_LU);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4384
		break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4385
	case e1000_media_type_internal_serdes:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4386
		ret_val = hw->mac.ops.check_for_link(hw);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4387
		link_active = adapter->hw.mac.serdes_has_link;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4388
		break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4389
	default:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4390
	case e1000_media_type_unknown:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4391
		break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4392
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4393
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4394
	if ((ret_val == E1000_ERR_PHY) && (hw->phy.type == e1000_phy_igp_3) &&
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4395
	    (er32(CTRL) & E1000_PHY_CTRL_GBE_DISABLE)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4396
		/* See e1000_kmrn_lock_loss_workaround_ich8lan() */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4397
		e_info("Gigabit has been disabled, downgrading speed\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4398
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4399
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4400
	return link_active;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4401
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4402
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4403
static void e1000e_enable_receives(struct e1000_adapter *adapter)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4404
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4405
	/* make sure the receive unit is started */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4406
	if ((adapter->flags & FLAG_RX_NEEDS_RESTART) &&
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4407
	    (adapter->flags & FLAG_RX_RESTART_NOW)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4408
		struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4409
		u32 rctl = er32(RCTL);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4410
		ew32(RCTL, rctl | E1000_RCTL_EN);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4411
		adapter->flags &= ~FLAG_RX_RESTART_NOW;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4412
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4413
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4414
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4415
static void e1000e_check_82574_phy_workaround(struct e1000_adapter *adapter)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4416
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4417
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4418
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4419
	/* With 82574 controllers, PHY needs to be checked periodically
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4420
	 * for hung state and reset, if two calls return true
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4421
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4422
	if (e1000_check_phy_82574(hw))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4423
		adapter->phy_hang_count++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4424
	else
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4425
		adapter->phy_hang_count = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4426
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4427
	if (adapter->phy_hang_count > 1) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4428
		adapter->phy_hang_count = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4429
		schedule_work(&adapter->reset_task);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4430
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4431
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4432
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4433
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4434
 * e1000_watchdog - Timer Call-back
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4435
 * @data: pointer to adapter cast into an unsigned long
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4436
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4437
static void e1000_watchdog(unsigned long data)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4438
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4439
	struct e1000_adapter *adapter = (struct e1000_adapter *) data;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4440
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4441
	/* Do the rest outside of interrupt context */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4442
	schedule_work(&adapter->watchdog_task);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4443
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4444
	/* TODO: make this use queue_delayed_work() */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4445
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4446
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4447
static void e1000_watchdog_task(struct work_struct *work)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4448
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4449
	struct e1000_adapter *adapter = container_of(work,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4450
					struct e1000_adapter, watchdog_task);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4451
	struct net_device *netdev = adapter->netdev;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4452
	struct e1000_mac_info *mac = &adapter->hw.mac;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4453
	struct e1000_phy_info *phy = &adapter->hw.phy;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4454
	struct e1000_ring *tx_ring = adapter->tx_ring;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4455
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4456
	u32 link, tctl;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4457
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4458
	if (test_bit(__E1000_DOWN, &adapter->state))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4459
		return;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4460
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4461
	link = e1000e_has_link(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4462
	if ((netif_carrier_ok(netdev)) && link) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4463
		/* Cancel scheduled suspend requests. */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4464
		pm_runtime_resume(netdev->dev.parent);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4465
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4466
		e1000e_enable_receives(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4467
		goto link_up;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4468
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4469
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4470
	if ((e1000e_enable_tx_pkt_filtering(hw)) &&
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4471
	    (adapter->mng_vlan_id != adapter->hw.mng_cookie.vlan_id))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4472
		e1000_update_mng_vlan(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4473
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4474
	if (link) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4475
		if (!netif_carrier_ok(netdev)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4476
			bool txb2b = true;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4477
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4478
			/* Cancel scheduled suspend requests. */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4479
			pm_runtime_resume(netdev->dev.parent);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4480
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4481
			/* update snapshot of PHY registers on LSC */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4482
			e1000_phy_read_status(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4483
			mac->ops.get_link_up_info(&adapter->hw,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4484
						   &adapter->link_speed,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4485
						   &adapter->link_duplex);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4486
			e1000_print_link_info(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4487
			/* On supported PHYs, check for duplex mismatch only
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4488
			 * if link has autonegotiated at 10/100 half
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4489
			 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4490
			if ((hw->phy.type == e1000_phy_igp_3 ||
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4491
			     hw->phy.type == e1000_phy_bm) &&
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4492
			    (hw->mac.autoneg == true) &&
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4493
			    (adapter->link_speed == SPEED_10 ||
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4494
			     adapter->link_speed == SPEED_100) &&
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4495
			    (adapter->link_duplex == HALF_DUPLEX)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4496
				u16 autoneg_exp;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4497
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4498
				e1e_rphy(hw, PHY_AUTONEG_EXP, &autoneg_exp);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4499
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4500
				if (!(autoneg_exp & NWAY_ER_LP_NWAY_CAPS))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4501
					e_info("Autonegotiated half duplex but link partner cannot autoneg.  Try forcing full duplex if link gets many collisions.\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4502
			}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4503
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4504
			/* adjust timeout factor according to speed/duplex */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4505
			adapter->tx_timeout_factor = 1;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4506
			switch (adapter->link_speed) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4507
			case SPEED_10:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4508
				txb2b = false;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4509
				adapter->tx_timeout_factor = 16;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4510
				break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4511
			case SPEED_100:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4512
				txb2b = false;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4513
				adapter->tx_timeout_factor = 10;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4514
				break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4515
			}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4516
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4517
			/* workaround: re-program speed mode bit after
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4518
			 * link-up event
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4519
			 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4520
			if ((adapter->flags & FLAG_TARC_SPEED_MODE_BIT) &&
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4521
			    !txb2b) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4522
				u32 tarc0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4523
				tarc0 = er32(TARC(0));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4524
				tarc0 &= ~SPEED_MODE_BIT;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4525
				ew32(TARC(0), tarc0);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4526
			}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4527
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4528
			/* disable TSO for pcie and 10/100 speeds, to avoid
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4529
			 * some hardware issues
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4530
			 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4531
			if (!(adapter->flags & FLAG_TSO_FORCE)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4532
				switch (adapter->link_speed) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4533
				case SPEED_10:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4534
				case SPEED_100:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4535
					e_info("10/100 speed: disabling TSO\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4536
					netdev->features &= ~NETIF_F_TSO;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4537
					netdev->features &= ~NETIF_F_TSO6;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4538
					break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4539
				case SPEED_1000:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4540
					netdev->features |= NETIF_F_TSO;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4541
					netdev->features |= NETIF_F_TSO6;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4542
					break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4543
				default:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4544
					/* oops */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4545
					break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4546
				}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4547
			}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4548
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4549
			/* enable transmits in the hardware, need to do this
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4550
			 * after setting TARC(0)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4551
			 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4552
			tctl = er32(TCTL);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4553
			tctl |= E1000_TCTL_EN;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4554
			ew32(TCTL, tctl);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4555
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4556
			/* Perform any post-link-up configuration before
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4557
			 * reporting link up.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4558
			 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4559
			if (phy->ops.cfg_on_link_up)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4560
				phy->ops.cfg_on_link_up(hw);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4561
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4562
			netif_carrier_on(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4563
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4564
			if (!test_bit(__E1000_DOWN, &adapter->state))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4565
				mod_timer(&adapter->phy_info_timer,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4566
					  round_jiffies(jiffies + 2 * HZ));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4567
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4568
	} else {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4569
		if (netif_carrier_ok(netdev)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4570
			adapter->link_speed = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4571
			adapter->link_duplex = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4572
			/* Link status message must follow this format */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4573
			printk(KERN_INFO "e1000e: %s NIC Link is Down\n",
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4574
			       adapter->netdev->name);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4575
			netif_carrier_off(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4576
			if (!test_bit(__E1000_DOWN, &adapter->state))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4577
				mod_timer(&adapter->phy_info_timer,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4578
					  round_jiffies(jiffies + 2 * HZ));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4579
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4580
			if (adapter->flags & FLAG_RX_NEEDS_RESTART)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4581
				schedule_work(&adapter->reset_task);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4582
			else
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4583
				pm_schedule_suspend(netdev->dev.parent,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4584
							LINK_TIMEOUT);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4585
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4586
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4587
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4588
link_up:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4589
	spin_lock(&adapter->stats64_lock);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4590
	e1000e_update_stats(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4591
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4592
	mac->tx_packet_delta = adapter->stats.tpt - adapter->tpt_old;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4593
	adapter->tpt_old = adapter->stats.tpt;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4594
	mac->collision_delta = adapter->stats.colc - adapter->colc_old;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4595
	adapter->colc_old = adapter->stats.colc;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4596
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4597
	adapter->gorc = adapter->stats.gorc - adapter->gorc_old;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4598
	adapter->gorc_old = adapter->stats.gorc;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4599
	adapter->gotc = adapter->stats.gotc - adapter->gotc_old;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4600
	adapter->gotc_old = adapter->stats.gotc;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4601
	spin_unlock(&adapter->stats64_lock);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4602
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4603
	e1000e_update_adaptive(&adapter->hw);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4604
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4605
	if (!netif_carrier_ok(netdev) &&
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4606
	    (e1000_desc_unused(tx_ring) + 1 < tx_ring->count)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4607
		/* We've lost link, so the controller stops DMA,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4608
		 * but we've got queued Tx work that's never going
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4609
		 * to get done, so reset controller to flush Tx.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4610
		 * (Do the reset outside of interrupt context).
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4611
		 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4612
		schedule_work(&adapter->reset_task);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4613
		/* return immediately since reset is imminent */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4614
		return;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4615
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4616
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4617
	/* Simple mode for Interrupt Throttle Rate (ITR) */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4618
	if (adapter->itr_setting == 4) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4619
		/* Symmetric Tx/Rx gets a reduced ITR=2000;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4620
		 * Total asymmetrical Tx or Rx gets ITR=8000;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4621
		 * everyone else is between 2000-8000.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4622
		 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4623
		u32 goc = (adapter->gotc + adapter->gorc) / 10000;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4624
		u32 dif = (adapter->gotc > adapter->gorc ?
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4625
			    adapter->gotc - adapter->gorc :
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4626
			    adapter->gorc - adapter->gotc) / 10000;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4627
		u32 itr = goc > 0 ? (dif * 6000 / goc + 2000) : 8000;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4628
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4629
		e1000e_write_itr(adapter, itr);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4630
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4631
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4632
	/* Cause software interrupt to ensure Rx ring is cleaned */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4633
	if (adapter->msix_entries)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4634
		ew32(ICS, adapter->rx_ring->ims_val);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4635
	else
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4636
		ew32(ICS, E1000_ICS_RXDMT0);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4637
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4638
	/* flush pending descriptors to memory before detecting Tx hang */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4639
	e1000e_flush_descriptors(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4640
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4641
	/* Force detection of hung controller every watchdog period */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4642
	adapter->detect_tx_hung = true;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4643
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4644
	/* With 82571 controllers, LAA may be overwritten due to controller
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4645
	 * reset from the other port. Set the appropriate LAA in RAR[0]
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4646
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4647
	if (e1000e_get_laa_state_82571(hw))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4648
		hw->mac.ops.rar_set(hw, adapter->hw.mac.addr, 0);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4649
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4650
	if (adapter->flags2 & FLAG2_CHECK_PHY_HANG)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4651
		e1000e_check_82574_phy_workaround(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4652
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4653
	/* Reset the timer */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4654
	if (!test_bit(__E1000_DOWN, &adapter->state))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4655
		mod_timer(&adapter->watchdog_timer,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4656
			  round_jiffies(jiffies + 2 * HZ));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4657
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4658
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4659
#define E1000_TX_FLAGS_CSUM		0x00000001
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4660
#define E1000_TX_FLAGS_VLAN		0x00000002
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4661
#define E1000_TX_FLAGS_TSO		0x00000004
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4662
#define E1000_TX_FLAGS_IPV4		0x00000008
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4663
#define E1000_TX_FLAGS_NO_FCS		0x00000010
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4664
#define E1000_TX_FLAGS_VLAN_MASK	0xffff0000
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4665
#define E1000_TX_FLAGS_VLAN_SHIFT	16
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4666
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4667
static int e1000_tso(struct e1000_ring *tx_ring, struct sk_buff *skb)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4668
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4669
	struct e1000_context_desc *context_desc;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4670
	struct e1000_buffer *buffer_info;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4671
	unsigned int i;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4672
	u32 cmd_length = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4673
	u16 ipcse = 0, mss;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4674
	u8 ipcss, ipcso, tucss, tucso, hdr_len;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4675
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4676
	if (!skb_is_gso(skb))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4677
		return 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4678
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4679
	if (skb_header_cloned(skb)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4680
		int err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4681
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4682
		if (err)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4683
			return err;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4684
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4685
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4686
	hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4687
	mss = skb_shinfo(skb)->gso_size;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4688
	if (skb->protocol == htons(ETH_P_IP)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4689
		struct iphdr *iph = ip_hdr(skb);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4690
		iph->tot_len = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4691
		iph->check = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4692
		tcp_hdr(skb)->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4693
		                                         0, IPPROTO_TCP, 0);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4694
		cmd_length = E1000_TXD_CMD_IP;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4695
		ipcse = skb_transport_offset(skb) - 1;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4696
	} else if (skb_is_gso_v6(skb)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4697
		ipv6_hdr(skb)->payload_len = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4698
		tcp_hdr(skb)->check = ~csum_ipv6_magic(&ipv6_hdr(skb)->saddr,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4699
		                                       &ipv6_hdr(skb)->daddr,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4700
		                                       0, IPPROTO_TCP, 0);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4701
		ipcse = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4702
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4703
	ipcss = skb_network_offset(skb);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4704
	ipcso = (void *)&(ip_hdr(skb)->check) - (void *)skb->data;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4705
	tucss = skb_transport_offset(skb);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4706
	tucso = (void *)&(tcp_hdr(skb)->check) - (void *)skb->data;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4707
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4708
	cmd_length |= (E1000_TXD_CMD_DEXT | E1000_TXD_CMD_TSE |
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4709
	               E1000_TXD_CMD_TCP | (skb->len - (hdr_len)));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4710
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4711
	i = tx_ring->next_to_use;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4712
	context_desc = E1000_CONTEXT_DESC(*tx_ring, i);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4713
	buffer_info = &tx_ring->buffer_info[i];
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4714
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4715
	context_desc->lower_setup.ip_fields.ipcss  = ipcss;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4716
	context_desc->lower_setup.ip_fields.ipcso  = ipcso;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4717
	context_desc->lower_setup.ip_fields.ipcse  = cpu_to_le16(ipcse);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4718
	context_desc->upper_setup.tcp_fields.tucss = tucss;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4719
	context_desc->upper_setup.tcp_fields.tucso = tucso;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4720
	context_desc->upper_setup.tcp_fields.tucse = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4721
	context_desc->tcp_seg_setup.fields.mss     = cpu_to_le16(mss);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4722
	context_desc->tcp_seg_setup.fields.hdr_len = hdr_len;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4723
	context_desc->cmd_and_length = cpu_to_le32(cmd_length);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4724
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4725
	buffer_info->time_stamp = jiffies;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4726
	buffer_info->next_to_watch = i;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4727
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4728
	i++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4729
	if (i == tx_ring->count)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4730
		i = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4731
	tx_ring->next_to_use = i;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4732
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4733
	return 1;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4734
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4735
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4736
static bool e1000_tx_csum(struct e1000_ring *tx_ring, struct sk_buff *skb)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4737
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4738
	struct e1000_adapter *adapter = tx_ring->adapter;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4739
	struct e1000_context_desc *context_desc;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4740
	struct e1000_buffer *buffer_info;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4741
	unsigned int i;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4742
	u8 css;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4743
	u32 cmd_len = E1000_TXD_CMD_DEXT;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4744
	__be16 protocol;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4745
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4746
	if (skb->ip_summed != CHECKSUM_PARTIAL)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4747
		return 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4748
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4749
	if (skb->protocol == cpu_to_be16(ETH_P_8021Q))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4750
		protocol = vlan_eth_hdr(skb)->h_vlan_encapsulated_proto;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4751
	else
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4752
		protocol = skb->protocol;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4753
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4754
	switch (protocol) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4755
	case cpu_to_be16(ETH_P_IP):
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4756
		if (ip_hdr(skb)->protocol == IPPROTO_TCP)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4757
			cmd_len |= E1000_TXD_CMD_TCP;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4758
		break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4759
	case cpu_to_be16(ETH_P_IPV6):
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4760
		/* XXX not handling all IPV6 headers */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4761
		if (ipv6_hdr(skb)->nexthdr == IPPROTO_TCP)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4762
			cmd_len |= E1000_TXD_CMD_TCP;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4763
		break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4764
	default:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4765
		if (unlikely(net_ratelimit()))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4766
			e_warn("checksum_partial proto=%x!\n",
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4767
			       be16_to_cpu(protocol));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4768
		break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4769
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4770
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4771
	css = skb_checksum_start_offset(skb);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4772
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4773
	i = tx_ring->next_to_use;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4774
	buffer_info = &tx_ring->buffer_info[i];
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4775
	context_desc = E1000_CONTEXT_DESC(*tx_ring, i);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4776
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4777
	context_desc->lower_setup.ip_config = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4778
	context_desc->upper_setup.tcp_fields.tucss = css;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4779
	context_desc->upper_setup.tcp_fields.tucso =
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4780
				css + skb->csum_offset;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4781
	context_desc->upper_setup.tcp_fields.tucse = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4782
	context_desc->tcp_seg_setup.data = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4783
	context_desc->cmd_and_length = cpu_to_le32(cmd_len);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4784
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4785
	buffer_info->time_stamp = jiffies;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4786
	buffer_info->next_to_watch = i;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4787
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4788
	i++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4789
	if (i == tx_ring->count)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4790
		i = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4791
	tx_ring->next_to_use = i;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4792
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4793
	return 1;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4794
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4795
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4796
static int e1000_tx_map(struct e1000_ring *tx_ring, struct sk_buff *skb,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4797
			unsigned int first, unsigned int max_per_txd,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4798
			unsigned int nr_frags)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4799
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4800
	struct e1000_adapter *adapter = tx_ring->adapter;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4801
	struct pci_dev *pdev = adapter->pdev;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4802
	struct e1000_buffer *buffer_info;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4803
	unsigned int len = skb_headlen(skb);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4804
	unsigned int offset = 0, size, count = 0, i;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4805
	unsigned int f, bytecount, segs;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4806
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4807
	i = tx_ring->next_to_use;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4808
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4809
	while (len) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4810
		buffer_info = &tx_ring->buffer_info[i];
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4811
		size = min(len, max_per_txd);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4812
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4813
		buffer_info->length = size;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4814
		buffer_info->time_stamp = jiffies;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4815
		buffer_info->next_to_watch = i;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4816
		buffer_info->dma = dma_map_single(&pdev->dev,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4817
						  skb->data + offset,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4818
						  size, DMA_TO_DEVICE);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4819
		buffer_info->mapped_as_page = false;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4820
		if (dma_mapping_error(&pdev->dev, buffer_info->dma))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4821
			goto dma_error;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4822
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4823
		len -= size;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4824
		offset += size;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4825
		count++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4826
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4827
		if (len) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4828
			i++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4829
			if (i == tx_ring->count)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4830
				i = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4831
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4832
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4833
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4834
	for (f = 0; f < nr_frags; f++) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4835
		const struct skb_frag_struct *frag;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4836
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4837
		frag = &skb_shinfo(skb)->frags[f];
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4838
		len = skb_frag_size(frag);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4839
		offset = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4840
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4841
		while (len) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4842
			i++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4843
			if (i == tx_ring->count)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4844
				i = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4845
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4846
			buffer_info = &tx_ring->buffer_info[i];
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4847
			size = min(len, max_per_txd);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4848
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4849
			buffer_info->length = size;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4850
			buffer_info->time_stamp = jiffies;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4851
			buffer_info->next_to_watch = i;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4852
			buffer_info->dma = skb_frag_dma_map(&pdev->dev, frag,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4853
						offset, size, DMA_TO_DEVICE);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4854
			buffer_info->mapped_as_page = true;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4855
			if (dma_mapping_error(&pdev->dev, buffer_info->dma))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4856
				goto dma_error;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4857
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4858
			len -= size;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4859
			offset += size;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4860
			count++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4861
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4862
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4863
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4864
	segs = skb_shinfo(skb)->gso_segs ? : 1;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4865
	/* multiply data chunks by size of headers */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4866
	bytecount = ((segs - 1) * skb_headlen(skb)) + skb->len;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4867
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4868
	tx_ring->buffer_info[i].skb = skb;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4869
	tx_ring->buffer_info[i].segs = segs;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4870
	tx_ring->buffer_info[i].bytecount = bytecount;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4871
	tx_ring->buffer_info[first].next_to_watch = i;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4872
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4873
	return count;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4874
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4875
dma_error:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4876
	dev_err(&pdev->dev, "Tx DMA map failed\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4877
	buffer_info->dma = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4878
	if (count)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4879
		count--;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4880
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4881
	while (count--) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4882
		if (i == 0)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4883
			i += tx_ring->count;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4884
		i--;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4885
		buffer_info = &tx_ring->buffer_info[i];
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4886
		e1000_put_txbuf(tx_ring, buffer_info);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4887
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4888
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4889
	return 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4890
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4891
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4892
static void e1000_tx_queue(struct e1000_ring *tx_ring, int tx_flags, int count)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4893
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4894
	struct e1000_adapter *adapter = tx_ring->adapter;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4895
	struct e1000_tx_desc *tx_desc = NULL;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4896
	struct e1000_buffer *buffer_info;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4897
	u32 txd_upper = 0, txd_lower = E1000_TXD_CMD_IFCS;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4898
	unsigned int i;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4899
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4900
	if (tx_flags & E1000_TX_FLAGS_TSO) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4901
		txd_lower |= E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D |
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4902
			     E1000_TXD_CMD_TSE;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4903
		txd_upper |= E1000_TXD_POPTS_TXSM << 8;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4904
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4905
		if (tx_flags & E1000_TX_FLAGS_IPV4)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4906
			txd_upper |= E1000_TXD_POPTS_IXSM << 8;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4907
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4908
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4909
	if (tx_flags & E1000_TX_FLAGS_CSUM) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4910
		txd_lower |= E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4911
		txd_upper |= E1000_TXD_POPTS_TXSM << 8;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4912
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4913
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4914
	if (tx_flags & E1000_TX_FLAGS_VLAN) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4915
		txd_lower |= E1000_TXD_CMD_VLE;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4916
		txd_upper |= (tx_flags & E1000_TX_FLAGS_VLAN_MASK);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4917
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4918
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4919
	if (unlikely(tx_flags & E1000_TX_FLAGS_NO_FCS))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4920
		txd_lower &= ~(E1000_TXD_CMD_IFCS);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4921
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4922
	i = tx_ring->next_to_use;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4923
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4924
	do {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4925
		buffer_info = &tx_ring->buffer_info[i];
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4926
		tx_desc = E1000_TX_DESC(*tx_ring, i);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4927
		tx_desc->buffer_addr = cpu_to_le64(buffer_info->dma);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4928
		tx_desc->lower.data =
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4929
			cpu_to_le32(txd_lower | buffer_info->length);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4930
		tx_desc->upper.data = cpu_to_le32(txd_upper);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4931
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4932
		i++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4933
		if (i == tx_ring->count)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4934
			i = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4935
	} while (--count > 0);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4936
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4937
	tx_desc->lower.data |= cpu_to_le32(adapter->txd_cmd);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4938
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4939
	/* txd_cmd re-enables FCS, so we'll re-disable it here as desired. */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4940
	if (unlikely(tx_flags & E1000_TX_FLAGS_NO_FCS))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4941
		tx_desc->lower.data &= ~(cpu_to_le32(E1000_TXD_CMD_IFCS));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4942
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4943
	/* Force memory writes to complete before letting h/w
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4944
	 * know there are new descriptors to fetch.  (Only
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4945
	 * applicable for weak-ordered memory model archs,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4946
	 * such as IA-64).
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4947
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4948
	wmb();
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4949
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4950
	tx_ring->next_to_use = i;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4951
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4952
	if (adapter->flags2 & FLAG2_PCIM2PCI_ARBITER_WA)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4953
		e1000e_update_tdt_wa(tx_ring, i);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4954
	else
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4955
		writel(i, tx_ring->tail);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4956
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4957
	/* we need this if more than one processor can write to our tail
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4958
	 * at a time, it synchronizes IO on IA64/Altix systems
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4959
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4960
	mmiowb();
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4961
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4962
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4963
#define MINIMUM_DHCP_PACKET_SIZE 282
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4964
static int e1000_transfer_dhcp_info(struct e1000_adapter *adapter,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4965
				    struct sk_buff *skb)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4966
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4967
	struct e1000_hw *hw =  &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4968
	u16 length, offset;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4969
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4970
	if (vlan_tx_tag_present(skb)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4971
		if (!((vlan_tx_tag_get(skb) == adapter->hw.mng_cookie.vlan_id) &&
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4972
		    (adapter->hw.mng_cookie.status &
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4973
			E1000_MNG_DHCP_COOKIE_STATUS_VLAN)))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4974
			return 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4975
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4976
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4977
	if (skb->len <= MINIMUM_DHCP_PACKET_SIZE)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4978
		return 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4979
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4980
	if (((struct ethhdr *) skb->data)->h_proto != htons(ETH_P_IP))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4981
		return 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4982
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4983
	{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4984
		const struct iphdr *ip = (struct iphdr *)((u8 *)skb->data+14);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4985
		struct udphdr *udp;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4986
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4987
		if (ip->protocol != IPPROTO_UDP)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4988
			return 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4989
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4990
		udp = (struct udphdr *)((u8 *)ip + (ip->ihl << 2));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4991
		if (ntohs(udp->dest) != 67)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4992
			return 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4993
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4994
		offset = (u8 *)udp + 8 - skb->data;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4995
		length = skb->len - offset;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4996
		return e1000e_mng_write_dhcp_info(hw, (u8 *)udp + 8, length);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4997
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4998
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4999
	return 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5000
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5001
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5002
static int __e1000_maybe_stop_tx(struct e1000_ring *tx_ring, int size)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5003
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5004
	struct e1000_adapter *adapter = tx_ring->adapter;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5005
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5006
	netif_stop_queue(adapter->netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5007
	/* Herbert's original patch had:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5008
	 *  smp_mb__after_netif_stop_queue();
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5009
	 * but since that doesn't exist yet, just open code it.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5010
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5011
	smp_mb();
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5012
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5013
	/* We need to check again in a case another CPU has just
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5014
	 * made room available.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5015
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5016
	if (e1000_desc_unused(tx_ring) < size)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5017
		return -EBUSY;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5018
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5019
	/* A reprieve! */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5020
	netif_start_queue(adapter->netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5021
	++adapter->restart_queue;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5022
	return 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5023
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5024
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5025
static int e1000_maybe_stop_tx(struct e1000_ring *tx_ring, int size)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5026
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5027
	BUG_ON(size > tx_ring->count);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5028
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5029
	if (e1000_desc_unused(tx_ring) >= size)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5030
		return 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5031
	return __e1000_maybe_stop_tx(tx_ring, size);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5032
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5033
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5034
static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5035
				    struct net_device *netdev)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5036
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5037
	struct e1000_adapter *adapter = netdev_priv(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5038
	struct e1000_ring *tx_ring = adapter->tx_ring;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5039
	unsigned int first;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5040
	unsigned int tx_flags = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5041
	unsigned int len = skb_headlen(skb);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5042
	unsigned int nr_frags;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5043
	unsigned int mss;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5044
	int count = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5045
	int tso;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5046
	unsigned int f;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5047
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5048
	if (test_bit(__E1000_DOWN, &adapter->state)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5049
		dev_kfree_skb_any(skb);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5050
		return NETDEV_TX_OK;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5051
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5052
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5053
	if (skb->len <= 0) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5054
		dev_kfree_skb_any(skb);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5055
		return NETDEV_TX_OK;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5056
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5057
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5058
	/* The minimum packet size with TCTL.PSP set is 17 bytes so
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5059
	 * pad skb in order to meet this minimum size requirement
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5060
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5061
	if (unlikely(skb->len < 17)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5062
		if (skb_pad(skb, 17 - skb->len))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5063
			return NETDEV_TX_OK;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5064
		skb->len = 17;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5065
		skb_set_tail_pointer(skb, 17);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5066
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5067
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5068
	mss = skb_shinfo(skb)->gso_size;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5069
	if (mss) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5070
		u8 hdr_len;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5071
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5072
		/* TSO Workaround for 82571/2/3 Controllers -- if skb->data
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5073
		 * points to just header, pull a few bytes of payload from
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5074
		 * frags into skb->data
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5075
		 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5076
		hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5077
		/* we do this workaround for ES2LAN, but it is un-necessary,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5078
		 * avoiding it could save a lot of cycles
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5079
		 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5080
		if (skb->data_len && (hdr_len == len)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5081
			unsigned int pull_size;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5082
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5083
			pull_size = min_t(unsigned int, 4, skb->data_len);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5084
			if (!__pskb_pull_tail(skb, pull_size)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5085
				e_err("__pskb_pull_tail failed.\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5086
				dev_kfree_skb_any(skb);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5087
				return NETDEV_TX_OK;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5088
			}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5089
			len = skb_headlen(skb);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5090
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5091
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5092
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5093
	/* reserve a descriptor for the offload context */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5094
	if ((mss) || (skb->ip_summed == CHECKSUM_PARTIAL))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5095
		count++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5096
	count++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5097
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5098
	count += DIV_ROUND_UP(len, adapter->tx_fifo_limit);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5099
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5100
	nr_frags = skb_shinfo(skb)->nr_frags;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5101
	for (f = 0; f < nr_frags; f++)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5102
		count += DIV_ROUND_UP(skb_frag_size(&skb_shinfo(skb)->frags[f]),
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5103
				      adapter->tx_fifo_limit);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5104
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5105
	if (adapter->hw.mac.tx_pkt_filtering)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5106
		e1000_transfer_dhcp_info(adapter, skb);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5107
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5108
	/* need: count + 2 desc gap to keep tail from touching
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5109
	 * head, otherwise try next time
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5110
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5111
	if (e1000_maybe_stop_tx(tx_ring, count + 2))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5112
		return NETDEV_TX_BUSY;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5113
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5114
	if (vlan_tx_tag_present(skb)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5115
		tx_flags |= E1000_TX_FLAGS_VLAN;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5116
		tx_flags |= (vlan_tx_tag_get(skb) << E1000_TX_FLAGS_VLAN_SHIFT);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5117
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5118
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5119
	first = tx_ring->next_to_use;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5120
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5121
	tso = e1000_tso(tx_ring, skb);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5122
	if (tso < 0) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5123
		dev_kfree_skb_any(skb);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5124
		return NETDEV_TX_OK;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5125
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5126
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5127
	if (tso)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5128
		tx_flags |= E1000_TX_FLAGS_TSO;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5129
	else if (e1000_tx_csum(tx_ring, skb))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5130
		tx_flags |= E1000_TX_FLAGS_CSUM;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5131
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5132
	/* Old method was to assume IPv4 packet by default if TSO was enabled.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5133
	 * 82571 hardware supports TSO capabilities for IPv6 as well...
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5134
	 * no longer assume, we must.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5135
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5136
	if (skb->protocol == htons(ETH_P_IP))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5137
		tx_flags |= E1000_TX_FLAGS_IPV4;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5138
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5139
	if (unlikely(skb->no_fcs))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5140
		tx_flags |= E1000_TX_FLAGS_NO_FCS;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5141
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5142
	/* if count is 0 then mapping error has occurred */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5143
	count = e1000_tx_map(tx_ring, skb, first, adapter->tx_fifo_limit,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5144
			     nr_frags);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5145
	if (count) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5146
		skb_tx_timestamp(skb);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5147
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5148
		netdev_sent_queue(netdev, skb->len);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5149
		e1000_tx_queue(tx_ring, tx_flags, count);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5150
		/* Make sure there is space in the ring for the next send. */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5151
		e1000_maybe_stop_tx(tx_ring,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5152
				    (MAX_SKB_FRAGS *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5153
				     DIV_ROUND_UP(PAGE_SIZE,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5154
						  adapter->tx_fifo_limit) + 2));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5155
	} else {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5156
		dev_kfree_skb_any(skb);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5157
		tx_ring->buffer_info[first].time_stamp = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5158
		tx_ring->next_to_use = first;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5159
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5160
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5161
	return NETDEV_TX_OK;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5162
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5163
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5164
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5165
 * e1000_tx_timeout - Respond to a Tx Hang
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5166
 * @netdev: network interface device structure
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5167
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5168
static void e1000_tx_timeout(struct net_device *netdev)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5169
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5170
	struct e1000_adapter *adapter = netdev_priv(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5171
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5172
	/* Do the reset outside of interrupt context */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5173
	adapter->tx_timeout_count++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5174
	schedule_work(&adapter->reset_task);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5175
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5176
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5177
static void e1000_reset_task(struct work_struct *work)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5178
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5179
	struct e1000_adapter *adapter;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5180
	adapter = container_of(work, struct e1000_adapter, reset_task);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5181
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5182
	/* don't run the task if already down */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5183
	if (test_bit(__E1000_DOWN, &adapter->state))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5184
		return;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5185
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5186
	if (!((adapter->flags & FLAG_RX_NEEDS_RESTART) &&
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5187
	      (adapter->flags & FLAG_RX_RESTART_NOW))) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5188
		e1000e_dump(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5189
		e_err("Reset adapter\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5190
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5191
	e1000e_reinit_locked(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5192
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5193
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5194
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5195
 * e1000_get_stats64 - Get System Network Statistics
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5196
 * @netdev: network interface device structure
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5197
 * @stats: rtnl_link_stats64 pointer
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5198
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5199
 * Returns the address of the device statistics structure.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5200
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5201
struct rtnl_link_stats64 *e1000e_get_stats64(struct net_device *netdev,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5202
                                             struct rtnl_link_stats64 *stats)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5203
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5204
	struct e1000_adapter *adapter = netdev_priv(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5205
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5206
	memset(stats, 0, sizeof(struct rtnl_link_stats64));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5207
	spin_lock(&adapter->stats64_lock);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5208
	e1000e_update_stats(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5209
	/* Fill out the OS statistics structure */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5210
	stats->rx_bytes = adapter->stats.gorc;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5211
	stats->rx_packets = adapter->stats.gprc;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5212
	stats->tx_bytes = adapter->stats.gotc;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5213
	stats->tx_packets = adapter->stats.gptc;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5214
	stats->multicast = adapter->stats.mprc;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5215
	stats->collisions = adapter->stats.colc;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5216
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5217
	/* Rx Errors */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5218
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5219
	/* RLEC on some newer hardware can be incorrect so build
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5220
	 * our own version based on RUC and ROC
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5221
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5222
	stats->rx_errors = adapter->stats.rxerrc +
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5223
		adapter->stats.crcerrs + adapter->stats.algnerrc +
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5224
		adapter->stats.ruc + adapter->stats.roc +
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5225
		adapter->stats.cexterr;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5226
	stats->rx_length_errors = adapter->stats.ruc +
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5227
					      adapter->stats.roc;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5228
	stats->rx_crc_errors = adapter->stats.crcerrs;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5229
	stats->rx_frame_errors = adapter->stats.algnerrc;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5230
	stats->rx_missed_errors = adapter->stats.mpc;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5231
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5232
	/* Tx Errors */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5233
	stats->tx_errors = adapter->stats.ecol +
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5234
				       adapter->stats.latecol;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5235
	stats->tx_aborted_errors = adapter->stats.ecol;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5236
	stats->tx_window_errors = adapter->stats.latecol;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5237
	stats->tx_carrier_errors = adapter->stats.tncrs;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5238
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5239
	/* Tx Dropped needs to be maintained elsewhere */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5240
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5241
	spin_unlock(&adapter->stats64_lock);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5242
	return stats;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5243
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5244
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5245
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5246
 * e1000_change_mtu - Change the Maximum Transfer Unit
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5247
 * @netdev: network interface device structure
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5248
 * @new_mtu: new value for maximum frame size
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5249
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5250
 * Returns 0 on success, negative on failure
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5251
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5252
static int e1000_change_mtu(struct net_device *netdev, int new_mtu)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5253
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5254
	struct e1000_adapter *adapter = netdev_priv(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5255
	int max_frame = new_mtu + ETH_HLEN + ETH_FCS_LEN;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5256
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5257
	/* Jumbo frame support */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5258
	if ((max_frame > ETH_FRAME_LEN + ETH_FCS_LEN) &&
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5259
	    !(adapter->flags & FLAG_HAS_JUMBO_FRAMES)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5260
		e_err("Jumbo Frames not supported.\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5261
		return -EINVAL;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5262
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5263
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5264
	/* Supported frame sizes */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5265
	if ((new_mtu < ETH_ZLEN + ETH_FCS_LEN + VLAN_HLEN) ||
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5266
	    (max_frame > adapter->max_hw_frame_size)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5267
		e_err("Unsupported MTU setting\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5268
		return -EINVAL;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5269
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5270
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5271
	/* Jumbo frame workaround on 82579 and newer requires CRC be stripped */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5272
	if ((adapter->hw.mac.type >= e1000_pch2lan) &&
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5273
	    !(adapter->flags2 & FLAG2_CRC_STRIPPING) &&
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5274
	    (new_mtu > ETH_DATA_LEN)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5275
		e_err("Jumbo Frames not supported on this device when CRC stripping is disabled.\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5276
		return -EINVAL;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5277
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5278
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5279
	while (test_and_set_bit(__E1000_RESETTING, &adapter->state))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5280
		usleep_range(1000, 2000);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5281
	/* e1000e_down -> e1000e_reset dependent on max_frame_size & mtu */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5282
	adapter->max_frame_size = max_frame;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5283
	e_info("changing MTU from %d to %d\n", netdev->mtu, new_mtu);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5284
	netdev->mtu = new_mtu;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5285
	if (netif_running(netdev))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5286
		e1000e_down(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5287
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5288
	/* NOTE: netdev_alloc_skb reserves 16 bytes, and typically NET_IP_ALIGN
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5289
	 * means we reserve 2 more, this pushes us to allocate from the next
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5290
	 * larger slab size.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5291
	 * i.e. RXBUFFER_2048 --> size-4096 slab
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5292
	 * However with the new *_jumbo_rx* routines, jumbo receives will use
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5293
	 * fragmented skbs
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5294
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5295
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5296
	if (max_frame <= 2048)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5297
		adapter->rx_buffer_len = 2048;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5298
	else
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5299
		adapter->rx_buffer_len = 4096;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5300
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5301
	/* adjust allocation if LPE protects us, and we aren't using SBP */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5302
	if ((max_frame == ETH_FRAME_LEN + ETH_FCS_LEN) ||
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5303
	     (max_frame == ETH_FRAME_LEN + VLAN_HLEN + ETH_FCS_LEN))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5304
		adapter->rx_buffer_len = ETH_FRAME_LEN + VLAN_HLEN
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5305
					 + ETH_FCS_LEN;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5306
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5307
	if (netif_running(netdev))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5308
		e1000e_up(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5309
	else
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5310
		e1000e_reset(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5311
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5312
	clear_bit(__E1000_RESETTING, &adapter->state);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5313
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5314
	return 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5315
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5316
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5317
static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5318
			   int cmd)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5319
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5320
	struct e1000_adapter *adapter = netdev_priv(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5321
	struct mii_ioctl_data *data = if_mii(ifr);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5322
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5323
	if (adapter->hw.phy.media_type != e1000_media_type_copper)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5324
		return -EOPNOTSUPP;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5325
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5326
	switch (cmd) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5327
	case SIOCGMIIPHY:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5328
		data->phy_id = adapter->hw.phy.addr;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5329
		break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5330
	case SIOCGMIIREG:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5331
		e1000_phy_read_status(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5332
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5333
		switch (data->reg_num & 0x1F) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5334
		case MII_BMCR:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5335
			data->val_out = adapter->phy_regs.bmcr;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5336
			break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5337
		case MII_BMSR:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5338
			data->val_out = adapter->phy_regs.bmsr;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5339
			break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5340
		case MII_PHYSID1:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5341
			data->val_out = (adapter->hw.phy.id >> 16);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5342
			break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5343
		case MII_PHYSID2:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5344
			data->val_out = (adapter->hw.phy.id & 0xFFFF);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5345
			break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5346
		case MII_ADVERTISE:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5347
			data->val_out = adapter->phy_regs.advertise;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5348
			break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5349
		case MII_LPA:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5350
			data->val_out = adapter->phy_regs.lpa;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5351
			break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5352
		case MII_EXPANSION:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5353
			data->val_out = adapter->phy_regs.expansion;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5354
			break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5355
		case MII_CTRL1000:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5356
			data->val_out = adapter->phy_regs.ctrl1000;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5357
			break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5358
		case MII_STAT1000:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5359
			data->val_out = adapter->phy_regs.stat1000;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5360
			break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5361
		case MII_ESTATUS:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5362
			data->val_out = adapter->phy_regs.estatus;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5363
			break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5364
		default:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5365
			return -EIO;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5366
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5367
		break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5368
	case SIOCSMIIREG:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5369
	default:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5370
		return -EOPNOTSUPP;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5371
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5372
	return 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5373
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5374
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5375
static int e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5376
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5377
	switch (cmd) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5378
	case SIOCGMIIPHY:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5379
	case SIOCGMIIREG:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5380
	case SIOCSMIIREG:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5381
		return e1000_mii_ioctl(netdev, ifr, cmd);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5382
	default:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5383
		return -EOPNOTSUPP;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5384
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5385
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5386
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5387
static int e1000_init_phy_wakeup(struct e1000_adapter *adapter, u32 wufc)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5388
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5389
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5390
	u32 i, mac_reg;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5391
	u16 phy_reg, wuc_enable;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5392
	int retval = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5393
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5394
	/* copy MAC RARs to PHY RARs */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5395
	e1000_copy_rx_addrs_to_phy_ich8lan(hw);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5396
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5397
	retval = hw->phy.ops.acquire(hw);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5398
	if (retval) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5399
		e_err("Could not acquire PHY\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5400
		return retval;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5401
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5402
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5403
	/* Enable access to wakeup registers on and set page to BM_WUC_PAGE */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5404
	retval = e1000_enable_phy_wakeup_reg_access_bm(hw, &wuc_enable);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5405
	if (retval)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5406
		goto release;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5407
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5408
	/* copy MAC MTA to PHY MTA - only needed for pchlan */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5409
	for (i = 0; i < adapter->hw.mac.mta_reg_count; i++) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5410
		mac_reg = E1000_READ_REG_ARRAY(hw, E1000_MTA, i);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5411
		hw->phy.ops.write_reg_page(hw, BM_MTA(i),
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5412
					   (u16)(mac_reg & 0xFFFF));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5413
		hw->phy.ops.write_reg_page(hw, BM_MTA(i) + 1,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5414
					   (u16)((mac_reg >> 16) & 0xFFFF));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5415
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5416
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5417
	/* configure PHY Rx Control register */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5418
	hw->phy.ops.read_reg_page(&adapter->hw, BM_RCTL, &phy_reg);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5419
	mac_reg = er32(RCTL);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5420
	if (mac_reg & E1000_RCTL_UPE)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5421
		phy_reg |= BM_RCTL_UPE;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5422
	if (mac_reg & E1000_RCTL_MPE)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5423
		phy_reg |= BM_RCTL_MPE;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5424
	phy_reg &= ~(BM_RCTL_MO_MASK);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5425
	if (mac_reg & E1000_RCTL_MO_3)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5426
		phy_reg |= (((mac_reg & E1000_RCTL_MO_3) >> E1000_RCTL_MO_SHIFT)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5427
				<< BM_RCTL_MO_SHIFT);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5428
	if (mac_reg & E1000_RCTL_BAM)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5429
		phy_reg |= BM_RCTL_BAM;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5430
	if (mac_reg & E1000_RCTL_PMCF)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5431
		phy_reg |= BM_RCTL_PMCF;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5432
	mac_reg = er32(CTRL);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5433
	if (mac_reg & E1000_CTRL_RFCE)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5434
		phy_reg |= BM_RCTL_RFCE;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5435
	hw->phy.ops.write_reg_page(&adapter->hw, BM_RCTL, phy_reg);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5436
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5437
	/* enable PHY wakeup in MAC register */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5438
	ew32(WUFC, wufc);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5439
	ew32(WUC, E1000_WUC_PHY_WAKE | E1000_WUC_PME_EN);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5440
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5441
	/* configure and enable PHY wakeup in PHY registers */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5442
	hw->phy.ops.write_reg_page(&adapter->hw, BM_WUFC, wufc);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5443
	hw->phy.ops.write_reg_page(&adapter->hw, BM_WUC, E1000_WUC_PME_EN);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5444
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5445
	/* activate PHY wakeup */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5446
	wuc_enable |= BM_WUC_ENABLE_BIT | BM_WUC_HOST_WU_BIT;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5447
	retval = e1000_disable_phy_wakeup_reg_access_bm(hw, &wuc_enable);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5448
	if (retval)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5449
		e_err("Could not set PHY Host Wakeup bit\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5450
release:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5451
	hw->phy.ops.release(hw);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5452
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5453
	return retval;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5454
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5455
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5456
static int __e1000_shutdown(struct pci_dev *pdev, bool runtime)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5457
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5458
	struct net_device *netdev = pci_get_drvdata(pdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5459
	struct e1000_adapter *adapter = netdev_priv(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5460
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5461
	u32 ctrl, ctrl_ext, rctl, status;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5462
	/* Runtime suspend should only enable wakeup for link changes */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5463
	u32 wufc = runtime ? E1000_WUFC_LNKC : adapter->wol;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5464
	int retval = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5465
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5466
	netif_device_detach(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5467
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5468
	if (netif_running(netdev)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5469
		int count = E1000_CHECK_RESET_COUNT;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5470
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5471
		while (test_bit(__E1000_RESETTING, &adapter->state) && count--)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5472
			usleep_range(10000, 20000);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5473
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5474
		WARN_ON(test_bit(__E1000_RESETTING, &adapter->state));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5475
		e1000e_down(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5476
		e1000_free_irq(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5477
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5478
	e1000e_reset_interrupt_capability(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5479
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5480
	status = er32(STATUS);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5481
	if (status & E1000_STATUS_LU)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5482
		wufc &= ~E1000_WUFC_LNKC;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5483
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5484
	if (wufc) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5485
		e1000_setup_rctl(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5486
		e1000e_set_rx_mode(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5487
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5488
		/* turn on all-multi mode if wake on multicast is enabled */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5489
		if (wufc & E1000_WUFC_MC) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5490
			rctl = er32(RCTL);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5491
			rctl |= E1000_RCTL_MPE;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5492
			ew32(RCTL, rctl);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5493
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5494
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5495
		ctrl = er32(CTRL);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5496
		/* advertise wake from D3Cold */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5497
		#define E1000_CTRL_ADVD3WUC 0x00100000
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5498
		/* phy power management enable */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5499
		#define E1000_CTRL_EN_PHY_PWR_MGMT 0x00200000
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5500
		ctrl |= E1000_CTRL_ADVD3WUC;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5501
		if (!(adapter->flags2 & FLAG2_HAS_PHY_WAKEUP))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5502
			ctrl |= E1000_CTRL_EN_PHY_PWR_MGMT;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5503
		ew32(CTRL, ctrl);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5504
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5505
		if (adapter->hw.phy.media_type == e1000_media_type_fiber ||
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5506
		    adapter->hw.phy.media_type ==
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5507
		    e1000_media_type_internal_serdes) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5508
			/* keep the laser running in D3 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5509
			ctrl_ext = er32(CTRL_EXT);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5510
			ctrl_ext |= E1000_CTRL_EXT_SDP3_DATA;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5511
			ew32(CTRL_EXT, ctrl_ext);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5512
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5513
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5514
		if (adapter->flags & FLAG_IS_ICH)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5515
			e1000_suspend_workarounds_ich8lan(&adapter->hw);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5516
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5517
		/* Allow time for pending master requests to run */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5518
		e1000e_disable_pcie_master(&adapter->hw);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5519
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5520
		if (adapter->flags2 & FLAG2_HAS_PHY_WAKEUP) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5521
			/* enable wakeup by the PHY */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5522
			retval = e1000_init_phy_wakeup(adapter, wufc);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5523
			if (retval)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5524
				return retval;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5525
		} else {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5526
			/* enable wakeup by the MAC */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5527
			ew32(WUFC, wufc);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5528
			ew32(WUC, E1000_WUC_PME_EN);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5529
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5530
	} else {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5531
		ew32(WUC, 0);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5532
		ew32(WUFC, 0);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5533
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5534
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5535
	if (adapter->hw.phy.type == e1000_phy_igp_3)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5536
		e1000e_igp3_phy_powerdown_workaround_ich8lan(&adapter->hw);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5537
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5538
	/* Release control of h/w to f/w.  If f/w is AMT enabled, this
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5539
	 * would have already happened in close and is redundant.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5540
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5541
	e1000e_release_hw_control(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5542
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5543
	pci_clear_master(pdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5544
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5545
	/* The pci-e switch on some quad port adapters will report a
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5546
	 * correctable error when the MAC transitions from D0 to D3.  To
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5547
	 * prevent this we need to mask off the correctable errors on the
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5548
	 * downstream port of the pci-e switch.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5549
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5550
	if (adapter->flags & FLAG_IS_QUAD_PORT) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5551
		struct pci_dev *us_dev = pdev->bus->self;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5552
		u16 devctl;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5553
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5554
		pcie_capability_read_word(us_dev, PCI_EXP_DEVCTL, &devctl);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5555
		pcie_capability_write_word(us_dev, PCI_EXP_DEVCTL,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5556
					   (devctl & ~PCI_EXP_DEVCTL_CERE));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5557
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5558
		pci_save_state(pdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5559
		pci_prepare_to_sleep(pdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5560
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5561
		pcie_capability_write_word(us_dev, PCI_EXP_DEVCTL, devctl);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5562
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5563
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5564
	return 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5565
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5566
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5567
#ifdef CONFIG_PCIEASPM
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5568
static void __e1000e_disable_aspm(struct pci_dev *pdev, u16 state)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5569
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5570
	pci_disable_link_state_locked(pdev, state);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5571
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5572
#else
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5573
static void __e1000e_disable_aspm(struct pci_dev *pdev, u16 state)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5574
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5575
	/* Both device and parent should have the same ASPM setting.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5576
	 * Disable ASPM in downstream component first and then upstream.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5577
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5578
	pcie_capability_clear_word(pdev, PCI_EXP_LNKCTL, state);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5579
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5580
	if (pdev->bus->self)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5581
		pcie_capability_clear_word(pdev->bus->self, PCI_EXP_LNKCTL,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5582
					   state);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5583
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5584
#endif
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5585
static void e1000e_disable_aspm(struct pci_dev *pdev, u16 state)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5586
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5587
	dev_info(&pdev->dev, "Disabling ASPM %s %s\n",
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5588
		 (state & PCIE_LINK_STATE_L0S) ? "L0s" : "",
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5589
		 (state & PCIE_LINK_STATE_L1) ? "L1" : "");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5590
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5591
	__e1000e_disable_aspm(pdev, state);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5592
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5593
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5594
#ifdef CONFIG_PM
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5595
static bool e1000e_pm_ready(struct e1000_adapter *adapter)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5596
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5597
	return !!adapter->tx_ring->buffer_info;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5598
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5599
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5600
static int __e1000_resume(struct pci_dev *pdev)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5601
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5602
	struct net_device *netdev = pci_get_drvdata(pdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5603
	struct e1000_adapter *adapter = netdev_priv(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5604
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5605
	u16 aspm_disable_flag = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5606
	u32 err;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5607
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5608
	if (adapter->flags2 & FLAG2_DISABLE_ASPM_L0S)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5609
		aspm_disable_flag = PCIE_LINK_STATE_L0S;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5610
	if (adapter->flags2 & FLAG2_DISABLE_ASPM_L1)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5611
		aspm_disable_flag |= PCIE_LINK_STATE_L1;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5612
	if (aspm_disable_flag)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5613
		e1000e_disable_aspm(pdev, aspm_disable_flag);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5614
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5615
	pci_set_master(pdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5616
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5617
	e1000e_set_interrupt_capability(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5618
	if (netif_running(netdev)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5619
		err = e1000_request_irq(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5620
		if (err)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5621
			return err;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5622
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5623
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5624
	if (hw->mac.type >= e1000_pch2lan)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5625
		e1000_resume_workarounds_pchlan(&adapter->hw);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5626
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5627
	e1000e_power_up_phy(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5628
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5629
	/* report the system wakeup cause from S3/S4 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5630
	if (adapter->flags2 & FLAG2_HAS_PHY_WAKEUP) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5631
		u16 phy_data;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5632
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5633
		e1e_rphy(&adapter->hw, BM_WUS, &phy_data);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5634
		if (phy_data) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5635
			e_info("PHY Wakeup cause - %s\n",
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5636
				phy_data & E1000_WUS_EX ? "Unicast Packet" :
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5637
				phy_data & E1000_WUS_MC ? "Multicast Packet" :
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5638
				phy_data & E1000_WUS_BC ? "Broadcast Packet" :
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5639
				phy_data & E1000_WUS_MAG ? "Magic Packet" :
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5640
				phy_data & E1000_WUS_LNKC ?
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5641
				"Link Status Change" : "other");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5642
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5643
		e1e_wphy(&adapter->hw, BM_WUS, ~0);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5644
	} else {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5645
		u32 wus = er32(WUS);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5646
		if (wus) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5647
			e_info("MAC Wakeup cause - %s\n",
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5648
				wus & E1000_WUS_EX ? "Unicast Packet" :
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5649
				wus & E1000_WUS_MC ? "Multicast Packet" :
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5650
				wus & E1000_WUS_BC ? "Broadcast Packet" :
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5651
				wus & E1000_WUS_MAG ? "Magic Packet" :
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5652
				wus & E1000_WUS_LNKC ? "Link Status Change" :
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5653
				"other");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5654
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5655
		ew32(WUS, ~0);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5656
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5657
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5658
	e1000e_reset(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5659
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5660
	e1000_init_manageability_pt(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5661
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5662
	if (netif_running(netdev))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5663
		e1000e_up(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5664
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5665
	netif_device_attach(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5666
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5667
	/* If the controller has AMT, do not set DRV_LOAD until the interface
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5668
	 * is up.  For all other cases, let the f/w know that the h/w is now
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5669
	 * under the control of the driver.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5670
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5671
	if (!(adapter->flags & FLAG_HAS_AMT))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5672
		e1000e_get_hw_control(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5673
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5674
	return 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5675
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5676
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5677
#ifdef CONFIG_PM_SLEEP
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5678
static int e1000_suspend(struct device *dev)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5679
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5680
	struct pci_dev *pdev = to_pci_dev(dev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5681
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5682
	return __e1000_shutdown(pdev, false);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5683
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5684
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5685
static int e1000_resume(struct device *dev)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5686
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5687
	struct pci_dev *pdev = to_pci_dev(dev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5688
	struct net_device *netdev = pci_get_drvdata(pdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5689
	struct e1000_adapter *adapter = netdev_priv(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5690
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5691
	if (e1000e_pm_ready(adapter))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5692
		adapter->idle_check = true;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5693
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5694
	return __e1000_resume(pdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5695
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5696
#endif /* CONFIG_PM_SLEEP */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5697
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5698
#ifdef CONFIG_PM_RUNTIME
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5699
static int e1000_runtime_suspend(struct device *dev)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5700
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5701
	struct pci_dev *pdev = to_pci_dev(dev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5702
	struct net_device *netdev = pci_get_drvdata(pdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5703
	struct e1000_adapter *adapter = netdev_priv(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5704
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5705
	if (!e1000e_pm_ready(adapter))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5706
		return 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5707
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5708
	return __e1000_shutdown(pdev, true);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5709
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5710
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5711
static int e1000_idle(struct device *dev)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5712
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5713
	struct pci_dev *pdev = to_pci_dev(dev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5714
	struct net_device *netdev = pci_get_drvdata(pdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5715
	struct e1000_adapter *adapter = netdev_priv(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5716
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5717
	if (!e1000e_pm_ready(adapter))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5718
		return 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5719
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5720
	if (adapter->idle_check) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5721
		adapter->idle_check = false;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5722
		if (!e1000e_has_link(adapter))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5723
			pm_schedule_suspend(dev, MSEC_PER_SEC);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5724
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5725
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5726
	return -EBUSY;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5727
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5728
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5729
static int e1000_runtime_resume(struct device *dev)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5730
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5731
	struct pci_dev *pdev = to_pci_dev(dev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5732
	struct net_device *netdev = pci_get_drvdata(pdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5733
	struct e1000_adapter *adapter = netdev_priv(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5734
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5735
	if (!e1000e_pm_ready(adapter))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5736
		return 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5737
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5738
	adapter->idle_check = !dev->power.runtime_auto;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5739
	return __e1000_resume(pdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5740
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5741
#endif /* CONFIG_PM_RUNTIME */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5742
#endif /* CONFIG_PM */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5743
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5744
static void e1000_shutdown(struct pci_dev *pdev)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5745
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5746
	__e1000_shutdown(pdev, false);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5747
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5748
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5749
#ifdef CONFIG_NET_POLL_CONTROLLER
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5750
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5751
static irqreturn_t e1000_intr_msix(int irq, void *data)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5752
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5753
	struct net_device *netdev = data;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5754
	struct e1000_adapter *adapter = netdev_priv(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5755
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5756
	if (adapter->msix_entries) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5757
		int vector, msix_irq;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5758
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5759
		vector = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5760
		msix_irq = adapter->msix_entries[vector].vector;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5761
		disable_irq(msix_irq);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5762
		e1000_intr_msix_rx(msix_irq, netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5763
		enable_irq(msix_irq);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5764
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5765
		vector++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5766
		msix_irq = adapter->msix_entries[vector].vector;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5767
		disable_irq(msix_irq);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5768
		e1000_intr_msix_tx(msix_irq, netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5769
		enable_irq(msix_irq);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5770
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5771
		vector++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5772
		msix_irq = adapter->msix_entries[vector].vector;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5773
		disable_irq(msix_irq);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5774
		e1000_msix_other(msix_irq, netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5775
		enable_irq(msix_irq);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5776
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5777
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5778
	return IRQ_HANDLED;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5779
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5780
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5781
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5782
 * e1000_netpoll
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5783
 * @netdev: network interface device structure
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5784
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5785
 * Polling 'interrupt' - used by things like netconsole to send skbs
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5786
 * without having to re-enable interrupts. It's not called while
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5787
 * the interrupt routine is executing.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5788
 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5789
static void e1000_netpoll(struct net_device *netdev)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5790
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5791
	struct e1000_adapter *adapter = netdev_priv(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5792
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5793
	switch (adapter->int_mode) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5794
	case E1000E_INT_MODE_MSIX:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5795
		e1000_intr_msix(adapter->pdev->irq, netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5796
		break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5797
	case E1000E_INT_MODE_MSI:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5798
		disable_irq(adapter->pdev->irq);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5799
		e1000_intr_msi(adapter->pdev->irq, netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5800
		enable_irq(adapter->pdev->irq);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5801
		break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5802
	default: /* E1000E_INT_MODE_LEGACY */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5803
		disable_irq(adapter->pdev->irq);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5804
		e1000_intr(adapter->pdev->irq, netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5805
		enable_irq(adapter->pdev->irq);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5806
		break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5807
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5808
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5809
#endif
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5810
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5811
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5812
 * e1000_io_error_detected - called when PCI error is detected
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5813
 * @pdev: Pointer to PCI device
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5814
 * @state: The current pci connection state
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5815
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5816
 * This function is called after a PCI bus error affecting
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5817
 * this device has been detected.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5818
 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5819
static pci_ers_result_t e1000_io_error_detected(struct pci_dev *pdev,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5820
						pci_channel_state_t state)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5821
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5822
	struct net_device *netdev = pci_get_drvdata(pdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5823
	struct e1000_adapter *adapter = netdev_priv(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5824
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5825
	netif_device_detach(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5826
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5827
	if (state == pci_channel_io_perm_failure)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5828
		return PCI_ERS_RESULT_DISCONNECT;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5829
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5830
	if (netif_running(netdev))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5831
		e1000e_down(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5832
	pci_disable_device(pdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5833
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5834
	/* Request a slot slot reset. */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5835
	return PCI_ERS_RESULT_NEED_RESET;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5836
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5837
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5838
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5839
 * e1000_io_slot_reset - called after the pci bus has been reset.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5840
 * @pdev: Pointer to PCI device
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5841
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5842
 * Restart the card from scratch, as if from a cold-boot. Implementation
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5843
 * resembles the first-half of the e1000_resume routine.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5844
 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5845
static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5846
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5847
	struct net_device *netdev = pci_get_drvdata(pdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5848
	struct e1000_adapter *adapter = netdev_priv(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5849
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5850
	u16 aspm_disable_flag = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5851
	int err;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5852
	pci_ers_result_t result;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5853
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5854
	if (adapter->flags2 & FLAG2_DISABLE_ASPM_L0S)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5855
		aspm_disable_flag = PCIE_LINK_STATE_L0S;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5856
	if (adapter->flags2 & FLAG2_DISABLE_ASPM_L1)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5857
		aspm_disable_flag |= PCIE_LINK_STATE_L1;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5858
	if (aspm_disable_flag)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5859
		e1000e_disable_aspm(pdev, aspm_disable_flag);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5860
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5861
	err = pci_enable_device_mem(pdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5862
	if (err) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5863
		dev_err(&pdev->dev,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5864
			"Cannot re-enable PCI device after reset.\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5865
		result = PCI_ERS_RESULT_DISCONNECT;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5866
	} else {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5867
		pdev->state_saved = true;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5868
		pci_restore_state(pdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5869
		pci_set_master(pdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5870
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5871
		pci_enable_wake(pdev, PCI_D3hot, 0);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5872
		pci_enable_wake(pdev, PCI_D3cold, 0);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5873
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5874
		e1000e_reset(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5875
		ew32(WUS, ~0);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5876
		result = PCI_ERS_RESULT_RECOVERED;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5877
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5878
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5879
	pci_cleanup_aer_uncorrect_error_status(pdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5880
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5881
	return result;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5882
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5883
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5884
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5885
 * e1000_io_resume - called when traffic can start flowing again.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5886
 * @pdev: Pointer to PCI device
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5887
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5888
 * This callback is called when the error recovery driver tells us that
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5889
 * its OK to resume normal operation. Implementation resembles the
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5890
 * second-half of the e1000_resume routine.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5891
 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5892
static void e1000_io_resume(struct pci_dev *pdev)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5893
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5894
	struct net_device *netdev = pci_get_drvdata(pdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5895
	struct e1000_adapter *adapter = netdev_priv(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5896
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5897
	e1000_init_manageability_pt(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5898
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5899
	if (netif_running(netdev)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5900
		if (e1000e_up(adapter)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5901
			dev_err(&pdev->dev,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5902
				"can't bring device back up after reset\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5903
			return;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5904
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5905
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5906
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5907
	netif_device_attach(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5908
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5909
	/* If the controller has AMT, do not set DRV_LOAD until the interface
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5910
	 * is up.  For all other cases, let the f/w know that the h/w is now
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5911
	 * under the control of the driver.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5912
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5913
	if (!(adapter->flags & FLAG_HAS_AMT))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5914
		e1000e_get_hw_control(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5915
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5916
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5917
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5918
static void e1000_print_device_info(struct e1000_adapter *adapter)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5919
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5920
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5921
	struct net_device *netdev = adapter->netdev;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5922
	u32 ret_val;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5923
	u8 pba_str[E1000_PBANUM_LENGTH];
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5924
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5925
	/* print bus type/speed/width info */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5926
	e_info("(PCI Express:2.5GT/s:%s) %pM\n",
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5927
	       /* bus width */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5928
	       ((hw->bus.width == e1000_bus_width_pcie_x4) ? "Width x4" :
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5929
	        "Width x1"),
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5930
	       /* MAC address */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5931
	       netdev->dev_addr);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5932
	e_info("Intel(R) PRO/%s Network Connection\n",
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5933
	       (hw->phy.type == e1000_phy_ife) ? "10/100" : "1000");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5934
	ret_val = e1000_read_pba_string_generic(hw, pba_str,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5935
						E1000_PBANUM_LENGTH);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5936
	if (ret_val)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5937
		strlcpy((char *)pba_str, "Unknown", sizeof(pba_str));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5938
	e_info("MAC: %d, PHY: %d, PBA No: %s\n",
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5939
	       hw->mac.type, hw->phy.type, pba_str);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5940
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5941
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5942
static void e1000_eeprom_checks(struct e1000_adapter *adapter)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5943
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5944
	struct e1000_hw *hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5945
	int ret_val;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5946
	u16 buf = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5947
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5948
	if (hw->mac.type != e1000_82573)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5949
		return;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5950
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5951
	ret_val = e1000_read_nvm(hw, NVM_INIT_CONTROL2_REG, 1, &buf);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5952
	le16_to_cpus(&buf);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5953
	if (!ret_val && (!(buf & (1 << 0)))) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5954
		/* Deep Smart Power Down (DSPD) */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5955
		dev_warn(&adapter->pdev->dev,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5956
			 "Warning: detected DSPD enabled in EEPROM\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5957
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5958
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5959
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5960
static int e1000_set_features(struct net_device *netdev,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5961
			      netdev_features_t features)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5962
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5963
	struct e1000_adapter *adapter = netdev_priv(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5964
	netdev_features_t changed = features ^ netdev->features;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5965
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5966
	if (changed & (NETIF_F_TSO | NETIF_F_TSO6))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5967
		adapter->flags |= FLAG_TSO_FORCE;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5968
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5969
	if (!(changed & (NETIF_F_HW_VLAN_RX | NETIF_F_HW_VLAN_TX |
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5970
			 NETIF_F_RXCSUM | NETIF_F_RXHASH | NETIF_F_RXFCS |
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5971
			 NETIF_F_RXALL)))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5972
		return 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5973
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5974
	if (changed & NETIF_F_RXFCS) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5975
		if (features & NETIF_F_RXFCS) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5976
			adapter->flags2 &= ~FLAG2_CRC_STRIPPING;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5977
		} else {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5978
			/* We need to take it back to defaults, which might mean
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5979
			 * stripping is still disabled at the adapter level.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5980
			 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5981
			if (adapter->flags2 & FLAG2_DFLT_CRC_STRIPPING)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5982
				adapter->flags2 |= FLAG2_CRC_STRIPPING;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5983
			else
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5984
				adapter->flags2 &= ~FLAG2_CRC_STRIPPING;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5985
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5986
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5987
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5988
	netdev->features = features;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5989
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5990
	if (netif_running(netdev))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5991
		e1000e_reinit_locked(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5992
	else
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5993
		e1000e_reset(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5994
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5995
	return 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5996
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5997
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5998
static const struct net_device_ops e1000e_netdev_ops = {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5999
	.ndo_open		= e1000_open,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6000
	.ndo_stop		= e1000_close,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6001
	.ndo_start_xmit		= e1000_xmit_frame,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6002
	.ndo_get_stats64	= e1000e_get_stats64,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6003
	.ndo_set_rx_mode	= e1000e_set_rx_mode,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6004
	.ndo_set_mac_address	= e1000_set_mac,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6005
	.ndo_change_mtu		= e1000_change_mtu,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6006
	.ndo_do_ioctl		= e1000_ioctl,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6007
	.ndo_tx_timeout		= e1000_tx_timeout,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6008
	.ndo_validate_addr	= eth_validate_addr,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6009
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6010
	.ndo_vlan_rx_add_vid	= e1000_vlan_rx_add_vid,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6011
	.ndo_vlan_rx_kill_vid	= e1000_vlan_rx_kill_vid,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6012
#ifdef CONFIG_NET_POLL_CONTROLLER
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6013
	.ndo_poll_controller	= e1000_netpoll,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6014
#endif
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6015
	.ndo_set_features = e1000_set_features,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6016
};
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6017
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6018
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6019
 * e1000_probe - Device Initialization Routine
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6020
 * @pdev: PCI device information struct
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6021
 * @ent: entry in e1000_pci_tbl
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6022
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6023
 * Returns 0 on success, negative on failure
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6024
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6025
 * e1000_probe initializes an adapter identified by a pci_dev structure.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6026
 * The OS initialization, configuring of the adapter private structure,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6027
 * and a hardware reset occur.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6028
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6029
static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6030
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6031
	struct net_device *netdev;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6032
	struct e1000_adapter *adapter;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6033
	struct e1000_hw *hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6034
	const struct e1000_info *ei = e1000_info_tbl[ent->driver_data];
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6035
	resource_size_t mmio_start, mmio_len;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6036
	resource_size_t flash_start, flash_len;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6037
	static int cards_found;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6038
	u16 aspm_disable_flag = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6039
	int i, err, pci_using_dac;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6040
	u16 eeprom_data = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6041
	u16 eeprom_apme_mask = E1000_EEPROM_APME;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6042
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6043
	if (ei->flags2 & FLAG2_DISABLE_ASPM_L0S)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6044
		aspm_disable_flag = PCIE_LINK_STATE_L0S;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6045
	if (ei->flags2 & FLAG2_DISABLE_ASPM_L1)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6046
		aspm_disable_flag |= PCIE_LINK_STATE_L1;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6047
	if (aspm_disable_flag)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6048
		e1000e_disable_aspm(pdev, aspm_disable_flag);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6049
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6050
	err = pci_enable_device_mem(pdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6051
	if (err)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6052
		return err;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6053
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6054
	pci_using_dac = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6055
	err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(64));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6056
	if (!err) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6057
		err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6058
		if (!err)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6059
			pci_using_dac = 1;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6060
	} else {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6061
		err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6062
		if (err) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6063
			err = dma_set_coherent_mask(&pdev->dev,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6064
						    DMA_BIT_MASK(32));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6065
			if (err) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6066
				dev_err(&pdev->dev, "No usable DMA configuration, aborting\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6067
				goto err_dma;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6068
			}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6069
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6070
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6071
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6072
	err = pci_request_selected_regions_exclusive(pdev,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6073
	                                  pci_select_bars(pdev, IORESOURCE_MEM),
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6074
	                                  e1000e_driver_name);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6075
	if (err)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6076
		goto err_pci_reg;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6077
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6078
	/* AER (Advanced Error Reporting) hooks */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6079
	pci_enable_pcie_error_reporting(pdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6080
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6081
	pci_set_master(pdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6082
	/* PCI config space info */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6083
	err = pci_save_state(pdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6084
	if (err)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6085
		goto err_alloc_etherdev;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6086
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6087
	err = -ENOMEM;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6088
	netdev = alloc_etherdev(sizeof(struct e1000_adapter));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6089
	if (!netdev)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6090
		goto err_alloc_etherdev;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6091
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6092
	SET_NETDEV_DEV(netdev, &pdev->dev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6093
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6094
	netdev->irq = pdev->irq;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6095
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6096
	pci_set_drvdata(pdev, netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6097
	adapter = netdev_priv(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6098
	hw = &adapter->hw;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6099
	adapter->netdev = netdev;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6100
	adapter->pdev = pdev;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6101
	adapter->ei = ei;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6102
	adapter->pba = ei->pba;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6103
	adapter->flags = ei->flags;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6104
	adapter->flags2 = ei->flags2;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6105
	adapter->hw.adapter = adapter;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6106
	adapter->hw.mac.type = ei->mac;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6107
	adapter->max_hw_frame_size = ei->max_hw_frame_size;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6108
	adapter->msg_enable = netif_msg_init(debug, DEFAULT_MSG_ENABLE);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6109
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6110
	mmio_start = pci_resource_start(pdev, 0);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6111
	mmio_len = pci_resource_len(pdev, 0);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6112
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6113
	err = -EIO;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6114
	adapter->hw.hw_addr = ioremap(mmio_start, mmio_len);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6115
	if (!adapter->hw.hw_addr)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6116
		goto err_ioremap;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6117
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6118
	if ((adapter->flags & FLAG_HAS_FLASH) &&
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6119
	    (pci_resource_flags(pdev, 1) & IORESOURCE_MEM)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6120
		flash_start = pci_resource_start(pdev, 1);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6121
		flash_len = pci_resource_len(pdev, 1);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6122
		adapter->hw.flash_address = ioremap(flash_start, flash_len);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6123
		if (!adapter->hw.flash_address)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6124
			goto err_flashmap;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6125
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6126
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6127
	/* construct the net_device struct */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6128
	netdev->netdev_ops		= &e1000e_netdev_ops;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6129
	e1000e_set_ethtool_ops(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6130
	netdev->watchdog_timeo		= 5 * HZ;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6131
	netif_napi_add(netdev, &adapter->napi, e1000e_poll, 64);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6132
	strlcpy(netdev->name, pci_name(pdev), sizeof(netdev->name));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6133
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6134
	netdev->mem_start = mmio_start;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6135
	netdev->mem_end = mmio_start + mmio_len;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6136
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6137
	adapter->bd_number = cards_found++;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6138
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6139
	e1000e_check_options(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6140
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6141
	/* setup adapter struct */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6142
	err = e1000_sw_init(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6143
	if (err)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6144
		goto err_sw_init;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6145
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6146
	memcpy(&hw->mac.ops, ei->mac_ops, sizeof(hw->mac.ops));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6147
	memcpy(&hw->nvm.ops, ei->nvm_ops, sizeof(hw->nvm.ops));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6148
	memcpy(&hw->phy.ops, ei->phy_ops, sizeof(hw->phy.ops));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6149
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6150
	err = ei->get_variants(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6151
	if (err)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6152
		goto err_hw_init;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6153
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6154
	if ((adapter->flags & FLAG_IS_ICH) &&
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6155
	    (adapter->flags & FLAG_READ_ONLY_NVM))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6156
		e1000e_write_protect_nvm_ich8lan(&adapter->hw);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6157
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6158
	hw->mac.ops.get_bus_info(&adapter->hw);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6159
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6160
	adapter->hw.phy.autoneg_wait_to_complete = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6161
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6162
	/* Copper options */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6163
	if (adapter->hw.phy.media_type == e1000_media_type_copper) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6164
		adapter->hw.phy.mdix = AUTO_ALL_MODES;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6165
		adapter->hw.phy.disable_polarity_correction = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6166
		adapter->hw.phy.ms_type = e1000_ms_hw_default;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6167
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6168
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6169
	if (hw->phy.ops.check_reset_block && hw->phy.ops.check_reset_block(hw))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6170
		dev_info(&pdev->dev,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6171
			 "PHY reset is blocked due to SOL/IDER session.\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6172
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6173
	/* Set initial default active device features */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6174
	netdev->features = (NETIF_F_SG |
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6175
			    NETIF_F_HW_VLAN_RX |
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6176
			    NETIF_F_HW_VLAN_TX |
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6177
			    NETIF_F_TSO |
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6178
			    NETIF_F_TSO6 |
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6179
			    NETIF_F_RXHASH |
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6180
			    NETIF_F_RXCSUM |
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6181
			    NETIF_F_HW_CSUM);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6182
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6183
	/* Set user-changeable features (subset of all device features) */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6184
	netdev->hw_features = netdev->features;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6185
	netdev->hw_features |= NETIF_F_RXFCS;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6186
	netdev->priv_flags |= IFF_SUPP_NOFCS;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6187
	netdev->hw_features |= NETIF_F_RXALL;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6188
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6189
	if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6190
		netdev->features |= NETIF_F_HW_VLAN_FILTER;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6191
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6192
	netdev->vlan_features |= (NETIF_F_SG |
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6193
				  NETIF_F_TSO |
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6194
				  NETIF_F_TSO6 |
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6195
				  NETIF_F_HW_CSUM);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6196
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6197
	netdev->priv_flags |= IFF_UNICAST_FLT;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6198
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6199
	if (pci_using_dac) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6200
		netdev->features |= NETIF_F_HIGHDMA;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6201
		netdev->vlan_features |= NETIF_F_HIGHDMA;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6202
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6203
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6204
	if (e1000e_enable_mng_pass_thru(&adapter->hw))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6205
		adapter->flags |= FLAG_MNG_PT_ENABLED;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6206
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6207
	/* before reading the NVM, reset the controller to
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6208
	 * put the device in a known good starting state
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6209
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6210
	adapter->hw.mac.ops.reset_hw(&adapter->hw);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6211
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6212
	/* systems with ASPM and others may see the checksum fail on the first
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6213
	 * attempt. Let's give it a few tries
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6214
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6215
	for (i = 0;; i++) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6216
		if (e1000_validate_nvm_checksum(&adapter->hw) >= 0)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6217
			break;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6218
		if (i == 2) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6219
			dev_err(&pdev->dev, "The NVM Checksum Is Not Valid\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6220
			err = -EIO;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6221
			goto err_eeprom;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6222
		}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6223
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6224
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6225
	e1000_eeprom_checks(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6226
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6227
	/* copy the MAC address */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6228
	if (e1000e_read_mac_addr(&adapter->hw))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6229
		dev_err(&pdev->dev,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6230
			"NVM Read Error while reading MAC address\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6231
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6232
	memcpy(netdev->dev_addr, adapter->hw.mac.addr, netdev->addr_len);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6233
	memcpy(netdev->perm_addr, adapter->hw.mac.addr, netdev->addr_len);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6234
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6235
	if (!is_valid_ether_addr(netdev->perm_addr)) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6236
		dev_err(&pdev->dev, "Invalid MAC Address: %pM\n",
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6237
			netdev->perm_addr);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6238
		err = -EIO;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6239
		goto err_eeprom;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6240
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6241
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6242
	init_timer(&adapter->watchdog_timer);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6243
	adapter->watchdog_timer.function = e1000_watchdog;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6244
	adapter->watchdog_timer.data = (unsigned long) adapter;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6245
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6246
	init_timer(&adapter->phy_info_timer);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6247
	adapter->phy_info_timer.function = e1000_update_phy_info;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6248
	adapter->phy_info_timer.data = (unsigned long) adapter;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6249
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6250
	INIT_WORK(&adapter->reset_task, e1000_reset_task);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6251
	INIT_WORK(&adapter->watchdog_task, e1000_watchdog_task);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6252
	INIT_WORK(&adapter->downshift_task, e1000e_downshift_workaround);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6253
	INIT_WORK(&adapter->update_phy_task, e1000e_update_phy_task);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6254
	INIT_WORK(&adapter->print_hang_task, e1000_print_hw_hang);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6255
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6256
	/* Initialize link parameters. User can change them with ethtool */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6257
	adapter->hw.mac.autoneg = 1;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6258
	adapter->fc_autoneg = true;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6259
	adapter->hw.fc.requested_mode = e1000_fc_default;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6260
	adapter->hw.fc.current_mode = e1000_fc_default;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6261
	adapter->hw.phy.autoneg_advertised = 0x2f;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6262
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6263
	/* ring size defaults */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6264
	adapter->rx_ring->count = E1000_DEFAULT_RXD;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6265
	adapter->tx_ring->count = E1000_DEFAULT_TXD;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6266
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6267
	/* Initial Wake on LAN setting - If APM wake is enabled in
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6268
	 * the EEPROM, enable the ACPI Magic Packet filter
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6269
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6270
	if (adapter->flags & FLAG_APME_IN_WUC) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6271
		/* APME bit in EEPROM is mapped to WUC.APME */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6272
		eeprom_data = er32(WUC);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6273
		eeprom_apme_mask = E1000_WUC_APME;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6274
		if ((hw->mac.type > e1000_ich10lan) &&
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6275
		    (eeprom_data & E1000_WUC_PHY_WAKE))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6276
			adapter->flags2 |= FLAG2_HAS_PHY_WAKEUP;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6277
	} else if (adapter->flags & FLAG_APME_IN_CTRL3) {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6278
		if (adapter->flags & FLAG_APME_CHECK_PORT_B &&
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6279
		    (adapter->hw.bus.func == 1))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6280
			e1000_read_nvm(&adapter->hw, NVM_INIT_CONTROL3_PORT_B,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6281
				       1, &eeprom_data);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6282
		else
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6283
			e1000_read_nvm(&adapter->hw, NVM_INIT_CONTROL3_PORT_A,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6284
				       1, &eeprom_data);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6285
	}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6286
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6287
	/* fetch WoL from EEPROM */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6288
	if (eeprom_data & eeprom_apme_mask)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6289
		adapter->eeprom_wol |= E1000_WUFC_MAG;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6290
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6291
	/* now that we have the eeprom settings, apply the special cases
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6292
	 * where the eeprom may be wrong or the board simply won't support
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6293
	 * wake on lan on a particular port
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6294
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6295
	if (!(adapter->flags & FLAG_HAS_WOL))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6296
		adapter->eeprom_wol = 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6297
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6298
	/* initialize the wol settings based on the eeprom settings */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6299
	adapter->wol = adapter->eeprom_wol;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6300
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6301
	/* make sure adapter isn't asleep if manageability is enabled */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6302
	if (adapter->wol || (adapter->flags & FLAG_MNG_PT_ENABLED) ||
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6303
	    (hw->mac.ops.check_mng_mode(hw)))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6304
		device_wakeup_enable(&pdev->dev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6305
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6306
	/* save off EEPROM version number */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6307
	e1000_read_nvm(&adapter->hw, 5, 1, &adapter->eeprom_vers);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6308
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6309
	/* reset the hardware with the new settings */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6310
	e1000e_reset(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6311
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6312
	/* If the controller has AMT, do not set DRV_LOAD until the interface
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6313
	 * is up.  For all other cases, let the f/w know that the h/w is now
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6314
	 * under the control of the driver.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6315
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6316
	if (!(adapter->flags & FLAG_HAS_AMT))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6317
		e1000e_get_hw_control(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6318
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6319
	strlcpy(netdev->name, "eth%d", sizeof(netdev->name));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6320
	err = register_netdev(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6321
	if (err)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6322
		goto err_register;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6323
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6324
	/* carrier off reporting is important to ethtool even BEFORE open */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6325
	netif_carrier_off(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6326
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6327
	e1000_print_device_info(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6328
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6329
	if (pci_dev_run_wake(pdev))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6330
		pm_runtime_put_noidle(&pdev->dev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6331
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6332
	return 0;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6333
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6334
err_register:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6335
	if (!(adapter->flags & FLAG_HAS_AMT))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6336
		e1000e_release_hw_control(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6337
err_eeprom:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6338
	if (hw->phy.ops.check_reset_block && !hw->phy.ops.check_reset_block(hw))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6339
		e1000_phy_hw_reset(&adapter->hw);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6340
err_hw_init:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6341
	kfree(adapter->tx_ring);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6342
	kfree(adapter->rx_ring);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6343
err_sw_init:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6344
	if (adapter->hw.flash_address)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6345
		iounmap(adapter->hw.flash_address);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6346
	e1000e_reset_interrupt_capability(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6347
err_flashmap:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6348
	iounmap(adapter->hw.hw_addr);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6349
err_ioremap:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6350
	free_netdev(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6351
err_alloc_etherdev:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6352
	pci_release_selected_regions(pdev,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6353
	                             pci_select_bars(pdev, IORESOURCE_MEM));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6354
err_pci_reg:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6355
err_dma:
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6356
	pci_disable_device(pdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6357
	return err;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6358
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6359
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6360
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6361
 * e1000_remove - Device Removal Routine
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6362
 * @pdev: PCI device information struct
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6363
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6364
 * e1000_remove is called by the PCI subsystem to alert the driver
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6365
 * that it should release a PCI device.  The could be caused by a
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6366
 * Hot-Plug event, or because the driver is going to be removed from
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6367
 * memory.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6368
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6369
static void e1000_remove(struct pci_dev *pdev)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6370
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6371
	struct net_device *netdev = pci_get_drvdata(pdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6372
	struct e1000_adapter *adapter = netdev_priv(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6373
	bool down = test_bit(__E1000_DOWN, &adapter->state);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6374
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6375
	/* The timers may be rescheduled, so explicitly disable them
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6376
	 * from being rescheduled.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6377
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6378
	if (!down)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6379
		set_bit(__E1000_DOWN, &adapter->state);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6380
	del_timer_sync(&adapter->watchdog_timer);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6381
	del_timer_sync(&adapter->phy_info_timer);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6382
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6383
	cancel_work_sync(&adapter->reset_task);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6384
	cancel_work_sync(&adapter->watchdog_task);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6385
	cancel_work_sync(&adapter->downshift_task);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6386
	cancel_work_sync(&adapter->update_phy_task);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6387
	cancel_work_sync(&adapter->print_hang_task);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6388
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6389
	if (!(netdev->flags & IFF_UP))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6390
		e1000_power_down_phy(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6391
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6392
	/* Don't lie to e1000_close() down the road. */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6393
	if (!down)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6394
		clear_bit(__E1000_DOWN, &adapter->state);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6395
	unregister_netdev(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6396
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6397
	if (pci_dev_run_wake(pdev))
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6398
		pm_runtime_get_noresume(&pdev->dev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6399
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6400
	/* Release control of h/w to f/w.  If f/w is AMT enabled, this
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6401
	 * would have already happened in close and is redundant.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6402
	 */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6403
	e1000e_release_hw_control(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6404
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6405
	e1000e_reset_interrupt_capability(adapter);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6406
	kfree(adapter->tx_ring);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6407
	kfree(adapter->rx_ring);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6408
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6409
	iounmap(adapter->hw.hw_addr);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6410
	if (adapter->hw.flash_address)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6411
		iounmap(adapter->hw.flash_address);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6412
	pci_release_selected_regions(pdev,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6413
	                             pci_select_bars(pdev, IORESOURCE_MEM));
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6414
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6415
	free_netdev(netdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6416
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6417
	/* AER disable */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6418
	pci_disable_pcie_error_reporting(pdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6419
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6420
	pci_disable_device(pdev);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6421
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6422
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6423
/* PCI Error Recovery (ERS) */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6424
static const struct pci_error_handlers e1000_err_handler = {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6425
	.error_detected = e1000_io_error_detected,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6426
	.slot_reset = e1000_io_slot_reset,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6427
	.resume = e1000_io_resume,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6428
};
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6429
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6430
static DEFINE_PCI_DEVICE_TABLE(e1000_pci_tbl) = {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6431
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_COPPER), board_82571 },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6432
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_FIBER), board_82571 },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6433
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_QUAD_COPPER), board_82571 },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6434
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_QUAD_COPPER_LP), board_82571 },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6435
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_QUAD_FIBER), board_82571 },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6436
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_SERDES), board_82571 },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6437
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_SERDES_DUAL), board_82571 },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6438
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_SERDES_QUAD), board_82571 },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6439
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82571PT_QUAD_COPPER), board_82571 },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6440
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6441
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82572EI), board_82572 },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6442
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82572EI_COPPER), board_82572 },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6443
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82572EI_FIBER), board_82572 },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6444
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82572EI_SERDES), board_82572 },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6445
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6446
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82573E), board_82573 },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6447
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82573E_IAMT), board_82573 },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6448
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82573L), board_82573 },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6449
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6450
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82574L), board_82574 },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6451
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82574LA), board_82574 },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6452
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_82583V), board_82583 },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6453
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6454
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_80003ES2LAN_COPPER_DPT),
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6455
	  board_80003es2lan },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6456
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_80003ES2LAN_COPPER_SPT),
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6457
	  board_80003es2lan },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6458
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_80003ES2LAN_SERDES_DPT),
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6459
	  board_80003es2lan },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6460
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_80003ES2LAN_SERDES_SPT),
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6461
	  board_80003es2lan },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6462
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6463
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH8_IFE), board_ich8lan },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6464
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH8_IFE_G), board_ich8lan },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6465
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH8_IFE_GT), board_ich8lan },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6466
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH8_IGP_AMT), board_ich8lan },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6467
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH8_IGP_C), board_ich8lan },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6468
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH8_IGP_M), board_ich8lan },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6469
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH8_IGP_M_AMT), board_ich8lan },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6470
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH8_82567V_3), board_ich8lan },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6471
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6472
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IFE), board_ich9lan },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6473
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IFE_G), board_ich9lan },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6474
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IFE_GT), board_ich9lan },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6475
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IGP_AMT), board_ich9lan },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6476
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IGP_C), board_ich9lan },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6477
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_BM), board_ich9lan },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6478
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IGP_M), board_ich9lan },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6479
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IGP_M_AMT), board_ich9lan },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6480
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IGP_M_V), board_ich9lan },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6481
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6482
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH10_R_BM_LM), board_ich9lan },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6483
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH10_R_BM_LF), board_ich9lan },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6484
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH10_R_BM_V), board_ich9lan },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6485
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6486
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH10_D_BM_LM), board_ich10lan },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6487
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH10_D_BM_LF), board_ich10lan },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6488
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH10_D_BM_V), board_ich10lan },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6489
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6490
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_M_HV_LM), board_pchlan },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6491
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_M_HV_LC), board_pchlan },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6492
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_D_HV_DM), board_pchlan },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6493
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_D_HV_DC), board_pchlan },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6494
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6495
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH2_LV_LM), board_pch2lan },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6496
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH2_LV_V), board_pch2lan },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6497
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6498
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_LPT_I217_LM), board_pch_lpt },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6499
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_LPT_I217_V), board_pch_lpt },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6500
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_LPTLP_I218_LM), board_pch_lpt },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6501
	{ PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_LPTLP_I218_V), board_pch_lpt },
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6502
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6503
	{ 0, 0, 0, 0, 0, 0, 0 }	/* terminate list */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6504
};
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6505
MODULE_DEVICE_TABLE(pci, e1000_pci_tbl);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6506
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6507
#ifdef CONFIG_PM
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6508
static const struct dev_pm_ops e1000_pm_ops = {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6509
	SET_SYSTEM_SLEEP_PM_OPS(e1000_suspend, e1000_resume)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6510
	SET_RUNTIME_PM_OPS(e1000_runtime_suspend,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6511
				e1000_runtime_resume, e1000_idle)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6512
};
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6513
#endif
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6514
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6515
/* PCI Device API Driver */
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6516
static struct pci_driver e1000_driver = {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6517
	.name     = e1000e_driver_name,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6518
	.id_table = e1000_pci_tbl,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6519
	.probe    = e1000_probe,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6520
	.remove   = e1000_remove,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6521
#ifdef CONFIG_PM
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6522
	.driver   = {
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6523
		.pm = &e1000_pm_ops,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6524
	},
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6525
#endif
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6526
	.shutdown = e1000_shutdown,
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6527
	.err_handler = &e1000_err_handler
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6528
};
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6529
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6530
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6531
 * e1000_init_module - Driver Registration Routine
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6532
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6533
 * e1000_init_module is the first routine called when the driver is
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6534
 * loaded. All it does is register with the PCI subsystem.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6535
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6536
static int __init e1000_init_module(void)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6537
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6538
	int ret;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6539
	pr_info("Intel(R) PRO/1000 Network Driver - %s\n",
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6540
		e1000e_driver_version);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6541
	pr_info("Copyright(c) 1999 - 2012 Intel Corporation.\n");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6542
	ret = pci_register_driver(&e1000_driver);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6543
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6544
	return ret;
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6545
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6546
module_init(e1000_init_module);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6547
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6548
/**
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6549
 * e1000_exit_module - Driver Exit Cleanup Routine
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6550
 *
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6551
 * e1000_exit_module is called just before the driver is removed
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6552
 * from memory.
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6553
 **/
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6554
static void __exit e1000_exit_module(void)
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6555
{
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6556
	pci_unregister_driver(&e1000_driver);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6557
}
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6558
module_exit(e1000_exit_module);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6559
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6560
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6561
MODULE_AUTHOR("Intel Corporation, <linux.nics@intel.com>");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6562
MODULE_DESCRIPTION("Intel(R) PRO/1000 Network Driver");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6563
MODULE_LICENSE("GPL");
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6564
MODULE_VERSION(DRV_VERSION);
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6565
0e3d989ff233 Added all drivers for kernel 3.8.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6566
/* netdev.c */