devices/e1000/e1000_main-2.6.27-ethercat.c
author Edouard Tisserant <edouard.tisserant@gmail.com>
Sun, 08 Jul 2018 13:33:09 +0200
branchstable-1.5
changeset 2699 ed6b9e0d7c05
parent 2582 87e502828b3f
permissions -rw-r--r--
Added --with-xenomai-config to override xenomai config command, also allowing special environment variables to be passed.

Example : --with-xenomai-config="DESTDIR=/path/to/staging /path/to/xeno-config"
1900
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/*******************************************************************************
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
  Intel PRO/1000 Linux driver
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
  Copyright(c) 1999 - 2006 Intel Corporation.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     5
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     6
  This program is free software; you can redistribute it and/or modify it
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     7
  under the terms and conditions of the GNU General Public License,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
  version 2, as published by the Free Software Foundation.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     9
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    10
  This program is distributed in the hope it will be useful, but WITHOUT
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    11
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    12
  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
  more details.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    14
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    15
  You should have received a copy of the GNU General Public License along with
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    16
  this program; if not, write to the Free Software Foundation, Inc.,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    17
  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    18
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    19
  The full GNU General Public License is included in this distribution in
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    20
  the file called "COPYING".
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    21
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    22
  Contact Information:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    23
  Linux NICS <linux.nics@intel.com>
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    24
  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    25
  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    26
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    27
  vim: noexpandtab
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    28
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
*******************************************************************************/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
#include "e1000-2.6.27-ethercat.h"
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
#include <net/ip6_checksum.h>
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
char e1000_driver_name[] = "ec_e1000";
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
static char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver";
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
#define DRV_VERSION "7.3.21-k3-NAPI"
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
const char e1000_driver_version[] = DRV_VERSION;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
static const char e1000_copyright[] = "Copyright (c) 1999-2006 Intel Corporation.";
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    39
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
/* e1000_pci_tbl - PCI Device ID Table
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
 * Last entry must be all 0s
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
 * Macro expands to...
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
 *   {PCI_DEVICE(PCI_VENDOR_ID_INTEL, device_id)}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
static struct pci_device_id e1000_pci_tbl[] = {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    48
	INTEL_E1000_ETHERNET_DEVICE(0x1000),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    49
	INTEL_E1000_ETHERNET_DEVICE(0x1001),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    50
	INTEL_E1000_ETHERNET_DEVICE(0x1004),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    51
	INTEL_E1000_ETHERNET_DEVICE(0x1008),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    52
	INTEL_E1000_ETHERNET_DEVICE(0x1009),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    53
	INTEL_E1000_ETHERNET_DEVICE(0x100C),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    54
	INTEL_E1000_ETHERNET_DEVICE(0x100D),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    55
	INTEL_E1000_ETHERNET_DEVICE(0x100E),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    56
	INTEL_E1000_ETHERNET_DEVICE(0x100F),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    57
	INTEL_E1000_ETHERNET_DEVICE(0x1010),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    58
	INTEL_E1000_ETHERNET_DEVICE(0x1011),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    59
	INTEL_E1000_ETHERNET_DEVICE(0x1012),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    60
	INTEL_E1000_ETHERNET_DEVICE(0x1013),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    61
	INTEL_E1000_ETHERNET_DEVICE(0x1014),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    62
	INTEL_E1000_ETHERNET_DEVICE(0x1015),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    63
	INTEL_E1000_ETHERNET_DEVICE(0x1016),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    64
	INTEL_E1000_ETHERNET_DEVICE(0x1017),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    65
	INTEL_E1000_ETHERNET_DEVICE(0x1018),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    66
	INTEL_E1000_ETHERNET_DEVICE(0x1019),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    67
	INTEL_E1000_ETHERNET_DEVICE(0x101A),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    68
	INTEL_E1000_ETHERNET_DEVICE(0x101D),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    69
	INTEL_E1000_ETHERNET_DEVICE(0x101E),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    70
	INTEL_E1000_ETHERNET_DEVICE(0x1026),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    71
	INTEL_E1000_ETHERNET_DEVICE(0x1027),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    72
	INTEL_E1000_ETHERNET_DEVICE(0x1028),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    73
	INTEL_E1000_ETHERNET_DEVICE(0x1075),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    74
	INTEL_E1000_ETHERNET_DEVICE(0x1076),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    75
	INTEL_E1000_ETHERNET_DEVICE(0x1077),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    76
	INTEL_E1000_ETHERNET_DEVICE(0x1078),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    77
	INTEL_E1000_ETHERNET_DEVICE(0x1079),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    78
	INTEL_E1000_ETHERNET_DEVICE(0x107A),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    79
	INTEL_E1000_ETHERNET_DEVICE(0x107B),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    80
	INTEL_E1000_ETHERNET_DEVICE(0x107C),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    81
	INTEL_E1000_ETHERNET_DEVICE(0x108A),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    82
	INTEL_E1000_ETHERNET_DEVICE(0x1099),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    83
	INTEL_E1000_ETHERNET_DEVICE(0x10B5),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    84
	/* required last entry */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    85
	{0,}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    86
};
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    87
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    88
// do not auto-load driver
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    89
// MODULE_DEVICE_TABLE(pci, e1000_pci_tbl);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    90
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    91
int e1000_up(struct e1000_adapter *adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    92
void e1000_down(struct e1000_adapter *adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    93
void e1000_reinit_locked(struct e1000_adapter *adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    94
void e1000_reset(struct e1000_adapter *adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    95
int e1000_set_spd_dplx(struct e1000_adapter *adapter, u16 spddplx);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    96
int e1000_setup_all_tx_resources(struct e1000_adapter *adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    97
int e1000_setup_all_rx_resources(struct e1000_adapter *adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    98
void e1000_free_all_tx_resources(struct e1000_adapter *adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    99
void e1000_free_all_rx_resources(struct e1000_adapter *adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   100
static int e1000_setup_tx_resources(struct e1000_adapter *adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   101
                             struct e1000_tx_ring *txdr);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   102
static int e1000_setup_rx_resources(struct e1000_adapter *adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   103
                             struct e1000_rx_ring *rxdr);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   104
static void e1000_free_tx_resources(struct e1000_adapter *adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   105
                             struct e1000_tx_ring *tx_ring);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   106
static void e1000_free_rx_resources(struct e1000_adapter *adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   107
                             struct e1000_rx_ring *rx_ring);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   108
void e1000_update_stats(struct e1000_adapter *adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   109
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   110
static int e1000_init_module(void);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   111
static void e1000_exit_module(void);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   112
static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   113
static void __devexit e1000_remove(struct pci_dev *pdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   114
static int e1000_alloc_queues(struct e1000_adapter *adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   115
static int e1000_sw_init(struct e1000_adapter *adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   116
static int e1000_open(struct net_device *netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   117
static int e1000_close(struct net_device *netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   118
static void e1000_configure_tx(struct e1000_adapter *adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   119
static void e1000_configure_rx(struct e1000_adapter *adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   120
static void e1000_setup_rctl(struct e1000_adapter *adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   121
static void e1000_clean_all_tx_rings(struct e1000_adapter *adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   122
static void e1000_clean_all_rx_rings(struct e1000_adapter *adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   123
static void e1000_clean_tx_ring(struct e1000_adapter *adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   124
                                struct e1000_tx_ring *tx_ring);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   125
static void e1000_clean_rx_ring(struct e1000_adapter *adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   126
                                struct e1000_rx_ring *rx_ring);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   127
static void e1000_set_rx_mode(struct net_device *netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   128
static void e1000_update_phy_info(unsigned long data);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   129
static void e1000_watchdog(unsigned long data);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   130
static void e1000_82547_tx_fifo_stall(unsigned long data);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   131
static int e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   132
static struct net_device_stats * e1000_get_stats(struct net_device *netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   133
static int e1000_change_mtu(struct net_device *netdev, int new_mtu);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   134
static int e1000_set_mac(struct net_device *netdev, void *p);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   135
void ec_poll(struct net_device *);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   136
static irqreturn_t e1000_intr(int irq, void *data);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   137
static irqreturn_t e1000_intr_msi(int irq, void *data);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   138
static bool e1000_clean_tx_irq(struct e1000_adapter *adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   139
			       struct e1000_tx_ring *tx_ring);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   140
static int e1000_clean(struct napi_struct *napi, int budget);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   141
static bool e1000_clean_rx_irq(struct e1000_adapter *adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   142
			       struct e1000_rx_ring *rx_ring,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   143
			       int *work_done, int work_to_do);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   144
static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   145
				  struct e1000_rx_ring *rx_ring,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   146
				  int *work_done, int work_to_do);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   147
static void e1000_alloc_rx_buffers(struct e1000_adapter *adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   148
                                   struct e1000_rx_ring *rx_ring,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   149
				   int cleaned_count);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   150
static void e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   151
                                      struct e1000_rx_ring *rx_ring,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   152
				      int cleaned_count);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   153
static int e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   154
static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   155
			   int cmd);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   156
static void e1000_enter_82542_rst(struct e1000_adapter *adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   157
static void e1000_leave_82542_rst(struct e1000_adapter *adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   158
static void e1000_tx_timeout(struct net_device *dev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   159
static void e1000_reset_task(struct work_struct *work);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   160
static void e1000_smartspeed(struct e1000_adapter *adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   161
static int e1000_82547_fifo_workaround(struct e1000_adapter *adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   162
                                       struct sk_buff *skb);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   163
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   164
static void e1000_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   165
static void e1000_vlan_rx_add_vid(struct net_device *netdev, u16 vid);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   166
static void e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   167
static void e1000_restore_vlan(struct e1000_adapter *adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   168
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   169
static int e1000_suspend(struct pci_dev *pdev, pm_message_t state);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   170
#ifdef CONFIG_PM
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   171
static int e1000_resume(struct pci_dev *pdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   172
#endif
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   173
static void e1000_shutdown(struct pci_dev *pdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   174
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   175
#ifdef CONFIG_NET_POLL_CONTROLLER
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   176
/* for netdump / net console */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   177
static void e1000_netpoll (struct net_device *netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   178
#endif
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   179
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   180
#define COPYBREAK_DEFAULT 256
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   181
static unsigned int copybreak __read_mostly = COPYBREAK_DEFAULT;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   182
module_param(copybreak, uint, 0644);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   183
MODULE_PARM_DESC(copybreak,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   184
	"Maximum size of packet that is copied to a new buffer on receive");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   185
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   186
static pci_ers_result_t e1000_io_error_detected(struct pci_dev *pdev,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   187
                     pci_channel_state_t state);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   188
static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   189
static void e1000_io_resume(struct pci_dev *pdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   190
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   191
static struct pci_error_handlers e1000_err_handler = {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   192
	.error_detected = e1000_io_error_detected,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   193
	.slot_reset = e1000_io_slot_reset,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   194
	.resume = e1000_io_resume,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   195
};
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   196
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   197
static struct pci_driver e1000_driver = {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   198
	.name     = e1000_driver_name,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   199
	.id_table = e1000_pci_tbl,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   200
	.probe    = e1000_probe,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   201
	.remove   = __devexit_p(e1000_remove),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   202
#ifdef CONFIG_PM
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   203
	/* Power Managment Hooks */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   204
	.suspend  = e1000_suspend,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   205
	.resume   = e1000_resume,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   206
#endif
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   207
	.shutdown = e1000_shutdown,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   208
	.err_handler = &e1000_err_handler
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   209
};
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   210
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   211
MODULE_AUTHOR("Florian Pose <fp@igh-essen.com>");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   212
MODULE_DESCRIPTION("EtherCAT-capable Intel(R) PRO/1000 Network Driver");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   213
MODULE_LICENSE("GPL");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   214
MODULE_VERSION(DRV_VERSION);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   215
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   216
static int debug = NETIF_MSG_DRV | NETIF_MSG_PROBE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   217
module_param(debug, int, 0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   218
MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   219
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   220
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   221
 * e1000_init_module - Driver Registration Routine
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   222
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   223
 * e1000_init_module is the first routine called when the driver is
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   224
 * loaded. All it does is register with the PCI subsystem.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   225
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   226
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   227
static int __init e1000_init_module(void)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   228
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   229
	int ret;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   230
	printk(KERN_INFO "%s - version %s\n",
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   231
	       e1000_driver_string, e1000_driver_version);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   232
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   233
	printk(KERN_INFO "%s\n", e1000_copyright);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   234
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   235
	ret = pci_register_driver(&e1000_driver);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   236
	if (copybreak != COPYBREAK_DEFAULT) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   237
		if (copybreak == 0)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   238
			printk(KERN_INFO "e1000: copybreak disabled\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   239
		else
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   240
			printk(KERN_INFO "e1000: copybreak enabled for "
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   241
			       "packets <= %u bytes\n", copybreak);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   242
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   243
	return ret;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   244
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   245
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   246
module_init(e1000_init_module);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   247
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   248
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   249
 * e1000_exit_module - Driver Exit Cleanup Routine
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   250
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   251
 * e1000_exit_module is called just before the driver is removed
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   252
 * from memory.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   253
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   254
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   255
static void __exit e1000_exit_module(void)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   256
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   257
	pci_unregister_driver(&e1000_driver);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   258
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   259
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   260
module_exit(e1000_exit_module);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   261
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   262
static int e1000_request_irq(struct e1000_adapter *adapter)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   263
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   264
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   265
	struct net_device *netdev = adapter->netdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   266
	irq_handler_t handler = e1000_intr;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   267
	int irq_flags = IRQF_SHARED;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   268
	int err;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   269
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   270
 	if (adapter->ecdev)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   271
 		return 0;
2421
bc2d4bf9cbe5 Removed trailing spaces.
Florian Pose <fp@igh-essen.com>
parents: 2252
diff changeset
   272
1900
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   273
	if (hw->mac_type >= e1000_82571) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   274
		adapter->have_msi = !pci_enable_msi(adapter->pdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   275
		if (adapter->have_msi) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   276
			handler = e1000_intr_msi;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   277
			irq_flags = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   278
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   279
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   280
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   281
	err = request_irq(adapter->pdev->irq, handler, irq_flags, netdev->name,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   282
	                  netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   283
	if (err) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   284
		if (adapter->have_msi)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   285
			pci_disable_msi(adapter->pdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   286
		DPRINTK(PROBE, ERR,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   287
		        "Unable to allocate interrupt Error: %d\n", err);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   288
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   289
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   290
	return err;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   291
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   292
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   293
static void e1000_free_irq(struct e1000_adapter *adapter)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   294
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   295
	struct net_device *netdev = adapter->netdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   296
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   297
	if (adapter->ecdev)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   298
		return;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   299
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   300
	free_irq(adapter->pdev->irq, netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   301
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   302
	if (adapter->have_msi)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   303
		pci_disable_msi(adapter->pdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   304
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   305
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   306
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   307
 * e1000_irq_disable - Mask off interrupt generation on the NIC
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   308
 * @adapter: board private structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   309
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   310
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   311
static void e1000_irq_disable(struct e1000_adapter *adapter)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   312
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   313
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   314
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   315
	if (adapter->ecdev)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   316
		return;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   317
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   318
	ew32(IMC, ~0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   319
	E1000_WRITE_FLUSH();
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   320
	synchronize_irq(adapter->pdev->irq);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   321
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   322
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   323
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   324
 * e1000_irq_enable - Enable default interrupt generation settings
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   325
 * @adapter: board private structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   326
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   327
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   328
static void e1000_irq_enable(struct e1000_adapter *adapter)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   329
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   330
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   331
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   332
	if (adapter->ecdev)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   333
		return;
2421
bc2d4bf9cbe5 Removed trailing spaces.
Florian Pose <fp@igh-essen.com>
parents: 2252
diff changeset
   334
1900
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   335
	ew32(IMS, IMS_ENABLE_MASK);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   336
	E1000_WRITE_FLUSH();
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   337
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   338
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   339
static void e1000_update_mng_vlan(struct e1000_adapter *adapter)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   340
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   341
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   342
	struct net_device *netdev = adapter->netdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   343
	u16 vid = hw->mng_cookie.vlan_id;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   344
	u16 old_vid = adapter->mng_vlan_id;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   345
	if (adapter->vlgrp) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   346
		if (!vlan_group_get_device(adapter->vlgrp, vid)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   347
			if (hw->mng_cookie.status &
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   348
				E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   349
				e1000_vlan_rx_add_vid(netdev, vid);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   350
				adapter->mng_vlan_id = vid;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   351
			} else
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   352
				adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   353
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   354
			if ((old_vid != (u16)E1000_MNG_VLAN_NONE) &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   355
					(vid != old_vid) &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   356
			    !vlan_group_get_device(adapter->vlgrp, old_vid))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   357
				e1000_vlan_rx_kill_vid(netdev, old_vid);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   358
		} else
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   359
			adapter->mng_vlan_id = vid;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   360
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   361
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   362
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   363
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   364
 * e1000_release_hw_control - release control of the h/w to f/w
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   365
 * @adapter: address of board private structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   366
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   367
 * e1000_release_hw_control resets {CTRL_EXT|FWSM}:DRV_LOAD bit.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   368
 * For ASF and Pass Through versions of f/w this means that the
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   369
 * driver is no longer loaded. For AMT version (only with 82573) i
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   370
 * of the f/w this means that the network i/f is closed.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   371
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   372
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   373
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   374
static void e1000_release_hw_control(struct e1000_adapter *adapter)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   375
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   376
	u32 ctrl_ext;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   377
	u32 swsm;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   378
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   379
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   380
	/* Let firmware taken over control of h/w */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   381
	switch (hw->mac_type) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   382
	case e1000_82573:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   383
		swsm = er32(SWSM);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   384
		ew32(SWSM, swsm & ~E1000_SWSM_DRV_LOAD);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   385
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   386
	case e1000_82571:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   387
	case e1000_82572:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   388
	case e1000_80003es2lan:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   389
	case e1000_ich8lan:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   390
		ctrl_ext = er32(CTRL_EXT);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   391
		ew32(CTRL_EXT, ctrl_ext & ~E1000_CTRL_EXT_DRV_LOAD);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   392
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   393
	default:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   394
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   395
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   396
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   397
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   398
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   399
 * e1000_get_hw_control - get control of the h/w from f/w
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   400
 * @adapter: address of board private structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   401
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   402
 * e1000_get_hw_control sets {CTRL_EXT|FWSM}:DRV_LOAD bit.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   403
 * For ASF and Pass Through versions of f/w this means that
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   404
 * the driver is loaded. For AMT version (only with 82573)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   405
 * of the f/w this means that the network i/f is open.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   406
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   407
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   408
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   409
static void e1000_get_hw_control(struct e1000_adapter *adapter)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   410
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   411
	u32 ctrl_ext;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   412
	u32 swsm;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   413
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   414
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   415
	/* Let firmware know the driver has taken over */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   416
	switch (hw->mac_type) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   417
	case e1000_82573:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   418
		swsm = er32(SWSM);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   419
		ew32(SWSM, swsm | E1000_SWSM_DRV_LOAD);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   420
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   421
	case e1000_82571:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   422
	case e1000_82572:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   423
	case e1000_80003es2lan:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   424
	case e1000_ich8lan:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   425
		ctrl_ext = er32(CTRL_EXT);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   426
		ew32(CTRL_EXT, ctrl_ext | E1000_CTRL_EXT_DRV_LOAD);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   427
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   428
	default:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   429
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   430
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   431
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   432
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   433
static void e1000_init_manageability(struct e1000_adapter *adapter)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   434
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   435
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   436
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   437
	if (adapter->en_mng_pt) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   438
		u32 manc = er32(MANC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   439
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   440
		/* disable hardware interception of ARP */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   441
		manc &= ~(E1000_MANC_ARP_EN);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   442
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   443
		/* enable receiving management packets to the host */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   444
		/* this will probably generate destination unreachable messages
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   445
		 * from the host OS, but the packets will be handled on SMBUS */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   446
		if (hw->has_manc2h) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   447
			u32 manc2h = er32(MANC2H);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   448
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   449
			manc |= E1000_MANC_EN_MNG2HOST;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   450
#define E1000_MNG2HOST_PORT_623 (1 << 5)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   451
#define E1000_MNG2HOST_PORT_664 (1 << 6)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   452
			manc2h |= E1000_MNG2HOST_PORT_623;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   453
			manc2h |= E1000_MNG2HOST_PORT_664;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   454
			ew32(MANC2H, manc2h);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   455
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   456
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   457
		ew32(MANC, manc);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   458
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   459
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   460
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   461
static void e1000_release_manageability(struct e1000_adapter *adapter)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   462
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   463
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   464
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   465
	if (adapter->en_mng_pt) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   466
		u32 manc = er32(MANC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   467
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   468
		/* re-enable hardware interception of ARP */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   469
		manc |= E1000_MANC_ARP_EN;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   470
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   471
		if (hw->has_manc2h)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   472
			manc &= ~E1000_MANC_EN_MNG2HOST;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   473
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   474
		/* don't explicitly have to mess with MANC2H since
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   475
		 * MANC has an enable disable that gates MANC2H */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   476
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   477
		ew32(MANC, manc);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   478
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   479
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   480
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   481
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   482
 * e1000_configure - configure the hardware for RX and TX
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   483
 * @adapter = private board structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   484
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   485
static void e1000_configure(struct e1000_adapter *adapter)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   486
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   487
	struct net_device *netdev = adapter->netdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   488
	int i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   489
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   490
	e1000_set_rx_mode(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   491
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   492
	e1000_restore_vlan(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   493
	e1000_init_manageability(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   494
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   495
	e1000_configure_tx(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   496
	e1000_setup_rctl(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   497
	e1000_configure_rx(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   498
	/* call E1000_DESC_UNUSED which always leaves
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   499
	 * at least 1 descriptor unused to make sure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   500
	 * next_to_use != next_to_clean */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   501
	for (i = 0; i < adapter->num_rx_queues; i++) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   502
		struct e1000_rx_ring *ring = &adapter->rx_ring[i];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   503
		if (adapter->ecdev) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   504
			/* fill rx ring completely! */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   505
			adapter->alloc_rx_buf(adapter, ring, ring->count);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   506
		} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   507
            /* this one leaves the last ring element unallocated! */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   508
			adapter->alloc_rx_buf(adapter, ring,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   509
					E1000_DESC_UNUSED(ring));
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   510
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   511
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   512
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   513
	adapter->tx_queue_len = netdev->tx_queue_len;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   514
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   515
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   516
int e1000_up(struct e1000_adapter *adapter)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   517
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   518
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   519
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   520
	/* hardware has been reset, we need to reload some things */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   521
	e1000_configure(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   522
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   523
	clear_bit(__E1000_DOWN, &adapter->flags);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   524
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   525
	if (!adapter->ecdev) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   526
		napi_enable(&adapter->napi);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   527
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   528
		e1000_irq_enable(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   529
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   530
		/* fire a link change interrupt to start the watchdog */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   531
		ew32(ICS, E1000_ICS_LSC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   532
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   533
	return 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   534
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   535
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   536
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   537
 * e1000_power_up_phy - restore link in case the phy was powered down
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   538
 * @adapter: address of board private structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   539
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   540
 * The phy may be powered down to save power and turn off link when the
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   541
 * driver is unloaded and wake on lan is not enabled (among others)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   542
 * *** this routine MUST be followed by a call to e1000_reset ***
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   543
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   544
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   545
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   546
void e1000_power_up_phy(struct e1000_adapter *adapter)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   547
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   548
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   549
	u16 mii_reg = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   550
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   551
	/* Just clear the power down bit to wake the phy back up */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   552
	if (hw->media_type == e1000_media_type_copper) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   553
		/* according to the manual, the phy will retain its
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   554
		 * settings across a power-down/up cycle */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   555
		e1000_read_phy_reg(hw, PHY_CTRL, &mii_reg);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   556
		mii_reg &= ~MII_CR_POWER_DOWN;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   557
		e1000_write_phy_reg(hw, PHY_CTRL, mii_reg);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   558
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   559
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   560
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   561
static void e1000_power_down_phy(struct e1000_adapter *adapter)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   562
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   563
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   564
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   565
	/* Power down the PHY so no link is implied when interface is down *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   566
	 * The PHY cannot be powered down if any of the following is true *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   567
	 * (a) WoL is enabled
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   568
	 * (b) AMT is active
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   569
	 * (c) SoL/IDER session is active */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   570
	if (!adapter->wol && hw->mac_type >= e1000_82540 &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   571
	   hw->media_type == e1000_media_type_copper) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   572
		u16 mii_reg = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   573
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   574
		switch (hw->mac_type) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   575
		case e1000_82540:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   576
		case e1000_82545:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   577
		case e1000_82545_rev_3:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   578
		case e1000_82546:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   579
		case e1000_82546_rev_3:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   580
		case e1000_82541:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   581
		case e1000_82541_rev_2:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   582
		case e1000_82547:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   583
		case e1000_82547_rev_2:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   584
			if (er32(MANC) & E1000_MANC_SMBUS_EN)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   585
				goto out;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   586
			break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   587
		case e1000_82571:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   588
		case e1000_82572:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   589
		case e1000_82573:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   590
		case e1000_80003es2lan:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   591
		case e1000_ich8lan:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   592
			if (e1000_check_mng_mode(hw) ||
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   593
			    e1000_check_phy_reset_block(hw))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   594
				goto out;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   595
			break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   596
		default:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   597
			goto out;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   598
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   599
		e1000_read_phy_reg(hw, PHY_CTRL, &mii_reg);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   600
		mii_reg |= MII_CR_POWER_DOWN;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   601
		e1000_write_phy_reg(hw, PHY_CTRL, mii_reg);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   602
		mdelay(1);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   603
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   604
out:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   605
	return;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   606
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   607
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   608
void e1000_down(struct e1000_adapter *adapter)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   609
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   610
	struct net_device *netdev = adapter->netdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   611
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   612
	/* signal that we're down so the interrupt handler does not
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   613
	 * reschedule our watchdog timer */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   614
	set_bit(__E1000_DOWN, &adapter->flags);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   615
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   616
	if (!adapter->ecdev) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   617
		napi_disable(&adapter->napi);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   618
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   619
		e1000_irq_disable(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   620
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   621
		del_timer_sync(&adapter->tx_fifo_stall_timer);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   622
		del_timer_sync(&adapter->watchdog_timer);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   623
		del_timer_sync(&adapter->phy_info_timer);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   624
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   625
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   626
	netdev->tx_queue_len = adapter->tx_queue_len;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   627
	adapter->link_speed = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   628
	adapter->link_duplex = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   629
 	if (!adapter->ecdev) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   630
		netif_carrier_off(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   631
		netif_stop_queue(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   632
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   633
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   634
	e1000_reset(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   635
	e1000_clean_all_tx_rings(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   636
	e1000_clean_all_rx_rings(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   637
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   638
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   639
void e1000_reinit_locked(struct e1000_adapter *adapter)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   640
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   641
	WARN_ON(in_interrupt());
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   642
	while (test_and_set_bit(__E1000_RESETTING, &adapter->flags))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   643
		msleep(1);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   644
	e1000_down(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   645
	e1000_up(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   646
	clear_bit(__E1000_RESETTING, &adapter->flags);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   647
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   648
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   649
void e1000_reset(struct e1000_adapter *adapter)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   650
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   651
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   652
	u32 pba = 0, tx_space, min_tx_space, min_rx_space;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   653
	u16 fc_high_water_mark = E1000_FC_HIGH_DIFF;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   654
	bool legacy_pba_adjust = false;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   655
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   656
	/* Repartition Pba for greater than 9k mtu
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   657
	 * To take effect CTRL.RST is required.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   658
	 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   659
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   660
	switch (hw->mac_type) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   661
	case e1000_82542_rev2_0:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   662
	case e1000_82542_rev2_1:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   663
	case e1000_82543:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   664
	case e1000_82544:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   665
	case e1000_82540:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   666
	case e1000_82541:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   667
	case e1000_82541_rev_2:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   668
		legacy_pba_adjust = true;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   669
		pba = E1000_PBA_48K;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   670
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   671
	case e1000_82545:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   672
	case e1000_82545_rev_3:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   673
	case e1000_82546:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   674
	case e1000_82546_rev_3:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   675
		pba = E1000_PBA_48K;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   676
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   677
	case e1000_82547:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   678
	case e1000_82547_rev_2:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   679
		legacy_pba_adjust = true;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   680
		pba = E1000_PBA_30K;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   681
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   682
	case e1000_82571:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   683
	case e1000_82572:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   684
	case e1000_80003es2lan:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   685
		pba = E1000_PBA_38K;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   686
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   687
	case e1000_82573:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   688
		pba = E1000_PBA_20K;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   689
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   690
	case e1000_ich8lan:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   691
		pba = E1000_PBA_8K;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   692
	case e1000_undefined:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   693
	case e1000_num_macs:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   694
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   695
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   696
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   697
	if (legacy_pba_adjust) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   698
		if (adapter->netdev->mtu > E1000_RXBUFFER_8192)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   699
			pba -= 8; /* allocate more FIFO for Tx */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   700
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   701
		if (hw->mac_type == e1000_82547) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   702
			adapter->tx_fifo_head = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   703
			adapter->tx_head_addr = pba << E1000_TX_HEAD_ADDR_SHIFT;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   704
			adapter->tx_fifo_size =
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   705
				(E1000_PBA_40K - pba) << E1000_PBA_BYTES_SHIFT;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   706
			atomic_set(&adapter->tx_fifo_stall, 0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   707
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   708
	} else if (hw->max_frame_size > MAXIMUM_ETHERNET_FRAME_SIZE) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   709
		/* adjust PBA for jumbo frames */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   710
		ew32(PBA, pba);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   711
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   712
		/* To maintain wire speed transmits, the Tx FIFO should be
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   713
		 * large enough to accomodate two full transmit packets,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   714
		 * rounded up to the next 1KB and expressed in KB.  Likewise,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   715
		 * the Rx FIFO should be large enough to accomodate at least
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   716
		 * one full receive packet and is similarly rounded up and
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   717
		 * expressed in KB. */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   718
		pba = er32(PBA);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   719
		/* upper 16 bits has Tx packet buffer allocation size in KB */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   720
		tx_space = pba >> 16;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   721
		/* lower 16 bits has Rx packet buffer allocation size in KB */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   722
		pba &= 0xffff;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   723
		/* don't include ethernet FCS because hardware appends/strips */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   724
		min_rx_space = adapter->netdev->mtu + ENET_HEADER_SIZE +
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   725
		               VLAN_TAG_SIZE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   726
		min_tx_space = min_rx_space;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   727
		min_tx_space *= 2;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   728
		min_tx_space = ALIGN(min_tx_space, 1024);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   729
		min_tx_space >>= 10;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   730
		min_rx_space = ALIGN(min_rx_space, 1024);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   731
		min_rx_space >>= 10;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   732
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   733
		/* If current Tx allocation is less than the min Tx FIFO size,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   734
		 * and the min Tx FIFO size is less than the current Rx FIFO
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   735
		 * allocation, take space away from current Rx allocation */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   736
		if (tx_space < min_tx_space &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   737
		    ((min_tx_space - tx_space) < pba)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   738
			pba = pba - (min_tx_space - tx_space);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   739
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   740
			/* PCI/PCIx hardware has PBA alignment constraints */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   741
			switch (hw->mac_type) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   742
			case e1000_82545 ... e1000_82546_rev_3:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   743
				pba &= ~(E1000_PBA_8K - 1);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   744
				break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   745
			default:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   746
				break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   747
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   748
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   749
			/* if short on rx space, rx wins and must trump tx
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   750
			 * adjustment or use Early Receive if available */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   751
			if (pba < min_rx_space) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   752
				switch (hw->mac_type) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   753
				case e1000_82573:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   754
					/* ERT enabled in e1000_configure_rx */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   755
					break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   756
				default:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   757
					pba = min_rx_space;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   758
					break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   759
				}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   760
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   761
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   762
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   763
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   764
	ew32(PBA, pba);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   765
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   766
	/* flow control settings */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   767
	/* Set the FC high water mark to 90% of the FIFO size.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   768
	 * Required to clear last 3 LSB */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   769
	fc_high_water_mark = ((pba * 9216)/10) & 0xFFF8;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   770
	/* We can't use 90% on small FIFOs because the remainder
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   771
	 * would be less than 1 full frame.  In this case, we size
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   772
	 * it to allow at least a full frame above the high water
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   773
	 *  mark. */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   774
	if (pba < E1000_PBA_16K)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   775
		fc_high_water_mark = (pba * 1024) - 1600;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   776
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   777
	hw->fc_high_water = fc_high_water_mark;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   778
	hw->fc_low_water = fc_high_water_mark - 8;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   779
	if (hw->mac_type == e1000_80003es2lan)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   780
		hw->fc_pause_time = 0xFFFF;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   781
	else
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   782
		hw->fc_pause_time = E1000_FC_PAUSE_TIME;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   783
	hw->fc_send_xon = 1;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   784
	hw->fc = hw->original_fc;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   785
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   786
	/* Allow time for pending master requests to run */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   787
	e1000_reset_hw(hw);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   788
	if (hw->mac_type >= e1000_82544)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   789
		ew32(WUC, 0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   790
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   791
	if (e1000_init_hw(hw))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   792
		DPRINTK(PROBE, ERR, "Hardware Error\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   793
	e1000_update_mng_vlan(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   794
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   795
	/* if (adapter->hwflags & HWFLAGS_PHY_PWR_BIT) { */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   796
	if (hw->mac_type >= e1000_82544 &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   797
	    hw->mac_type <= e1000_82547_rev_2 &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   798
	    hw->autoneg == 1 &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   799
	    hw->autoneg_advertised == ADVERTISE_1000_FULL) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   800
		u32 ctrl = er32(CTRL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   801
		/* clear phy power management bit if we are in gig only mode,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   802
		 * which if enabled will attempt negotiation to 100Mb, which
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   803
		 * can cause a loss of link at power off or driver unload */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   804
		ctrl &= ~E1000_CTRL_SWDPIN3;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   805
		ew32(CTRL, ctrl);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   806
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   807
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   808
	/* Enable h/w to recognize an 802.1Q VLAN Ethernet packet */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   809
	ew32(VET, ETHERNET_IEEE_VLAN_TYPE);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   810
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   811
	e1000_reset_adaptive(hw);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   812
	e1000_phy_get_info(hw, &adapter->phy_info);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   813
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   814
	if (!adapter->smart_power_down &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   815
	    (hw->mac_type == e1000_82571 ||
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   816
	     hw->mac_type == e1000_82572)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   817
		u16 phy_data = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   818
		/* speed up time to link by disabling smart power down, ignore
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   819
		 * the return value of this function because there is nothing
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   820
		 * different we would do if it failed */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   821
		e1000_read_phy_reg(hw, IGP02E1000_PHY_POWER_MGMT,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   822
		                   &phy_data);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   823
		phy_data &= ~IGP02E1000_PM_SPD;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   824
		e1000_write_phy_reg(hw, IGP02E1000_PHY_POWER_MGMT,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   825
		                    phy_data);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   826
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   827
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   828
	e1000_release_manageability(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   829
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   830
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   831
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   832
 *  Dump the eeprom for users having checksum issues
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   833
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   834
static void e1000_dump_eeprom(struct e1000_adapter *adapter)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   835
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   836
	struct net_device *netdev = adapter->netdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   837
	struct ethtool_eeprom eeprom;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   838
	const struct ethtool_ops *ops = netdev->ethtool_ops;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   839
	u8 *data;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   840
	int i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   841
	u16 csum_old, csum_new = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   842
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   843
	eeprom.len = ops->get_eeprom_len(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   844
	eeprom.offset = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   845
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   846
	data = kmalloc(eeprom.len, GFP_KERNEL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   847
	if (!data) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   848
		printk(KERN_ERR "Unable to allocate memory to dump EEPROM"
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   849
		       " data\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   850
		return;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   851
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   852
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   853
	ops->get_eeprom(netdev, &eeprom, data);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   854
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   855
	csum_old = (data[EEPROM_CHECKSUM_REG * 2]) +
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   856
		   (data[EEPROM_CHECKSUM_REG * 2 + 1] << 8);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   857
	for (i = 0; i < EEPROM_CHECKSUM_REG * 2; i += 2)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   858
		csum_new += data[i] + (data[i + 1] << 8);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   859
	csum_new = EEPROM_SUM - csum_new;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   860
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   861
	printk(KERN_ERR "/*********************/\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   862
	printk(KERN_ERR "Current EEPROM Checksum : 0x%04x\n", csum_old);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   863
	printk(KERN_ERR "Calculated              : 0x%04x\n", csum_new);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   864
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   865
	printk(KERN_ERR "Offset    Values\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   866
	printk(KERN_ERR "========  ======\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   867
	print_hex_dump(KERN_ERR, "", DUMP_PREFIX_OFFSET, 16, 1, data, 128, 0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   868
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   869
	printk(KERN_ERR "Include this output when contacting your support "
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   870
	       "provider.\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   871
	printk(KERN_ERR "This is not a software error! Something bad "
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   872
	       "happened to your hardware or\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   873
	printk(KERN_ERR "EEPROM image. Ignoring this "
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   874
	       "problem could result in further problems,\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   875
	printk(KERN_ERR "possibly loss of data, corruption or system hangs!\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   876
	printk(KERN_ERR "The MAC Address will be reset to 00:00:00:00:00:00, "
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   877
	       "which is invalid\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   878
	printk(KERN_ERR "and requires you to set the proper MAC "
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   879
	       "address manually before continuing\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   880
	printk(KERN_ERR "to enable this network device.\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   881
	printk(KERN_ERR "Please inspect the EEPROM dump and report the issue "
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   882
	       "to your hardware vendor\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   883
	printk(KERN_ERR "or Intel Customer Support.\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   884
	printk(KERN_ERR "/*********************/\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   885
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   886
	kfree(data);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   887
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   888
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   889
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   890
 * e1000_is_need_ioport - determine if an adapter needs ioport resources or not
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   891
 * @pdev: PCI device information struct
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   892
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   893
 * Return true if an adapter needs ioport resources
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   894
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   895
static int e1000_is_need_ioport(struct pci_dev *pdev)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   896
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   897
	switch (pdev->device) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   898
	case E1000_DEV_ID_82540EM:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   899
	case E1000_DEV_ID_82540EM_LOM:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   900
	case E1000_DEV_ID_82540EP:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   901
	case E1000_DEV_ID_82540EP_LOM:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   902
	case E1000_DEV_ID_82540EP_LP:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   903
	case E1000_DEV_ID_82541EI:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   904
	case E1000_DEV_ID_82541EI_MOBILE:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   905
	case E1000_DEV_ID_82541ER:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   906
	case E1000_DEV_ID_82541ER_LOM:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   907
	case E1000_DEV_ID_82541GI:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   908
	case E1000_DEV_ID_82541GI_LF:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   909
	case E1000_DEV_ID_82541GI_MOBILE:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   910
	case E1000_DEV_ID_82544EI_COPPER:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   911
	case E1000_DEV_ID_82544EI_FIBER:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   912
	case E1000_DEV_ID_82544GC_COPPER:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   913
	case E1000_DEV_ID_82544GC_LOM:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   914
	case E1000_DEV_ID_82545EM_COPPER:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   915
	case E1000_DEV_ID_82545EM_FIBER:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   916
	case E1000_DEV_ID_82546EB_COPPER:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   917
	case E1000_DEV_ID_82546EB_FIBER:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   918
	case E1000_DEV_ID_82546EB_QUAD_COPPER:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   919
		return true;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   920
	default:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   921
		return false;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   922
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   923
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   924
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   925
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   926
 * e1000_probe - Device Initialization Routine
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   927
 * @pdev: PCI device information struct
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   928
 * @ent: entry in e1000_pci_tbl
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   929
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   930
 * Returns 0 on success, negative on failure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   931
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   932
 * e1000_probe initializes an adapter identified by a pci_dev structure.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   933
 * The OS initialization, configuring of the adapter private structure,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   934
 * and a hardware reset occur.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   935
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   936
static int __devinit e1000_probe(struct pci_dev *pdev,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   937
				 const struct pci_device_id *ent)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   938
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   939
	struct net_device *netdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   940
	struct e1000_adapter *adapter;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   941
	struct e1000_hw *hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   942
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   943
	static int cards_found = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   944
	static int global_quad_port_a = 0; /* global ksp3 port a indication */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   945
	int i, err, pci_using_dac;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   946
	u16 eeprom_data = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   947
	u16 eeprom_apme_mask = E1000_EEPROM_APME;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   948
	int bars, need_ioport;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   949
	DECLARE_MAC_BUF(mac);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   950
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   951
	/* do not allocate ioport bars when not needed */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   952
	need_ioport = e1000_is_need_ioport(pdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   953
	if (need_ioport) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   954
		bars = pci_select_bars(pdev, IORESOURCE_MEM | IORESOURCE_IO);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   955
		err = pci_enable_device(pdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   956
	} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   957
		bars = pci_select_bars(pdev, IORESOURCE_MEM);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   958
		err = pci_enable_device_mem(pdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   959
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   960
	if (err)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   961
		return err;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   962
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   963
	if (!pci_set_dma_mask(pdev, DMA_64BIT_MASK) &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   964
	    !pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   965
		pci_using_dac = 1;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   966
	} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   967
		err = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   968
		if (err) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   969
			err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   970
			if (err) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   971
				E1000_ERR("No usable DMA configuration, "
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   972
					  "aborting\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   973
				goto err_dma;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   974
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   975
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   976
		pci_using_dac = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   977
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   978
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   979
	err = pci_request_selected_regions(pdev, bars, e1000_driver_name);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   980
	if (err)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   981
		goto err_pci_reg;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   982
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   983
	pci_set_master(pdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   984
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   985
	err = -ENOMEM;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   986
	netdev = alloc_etherdev(sizeof(struct e1000_adapter));
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   987
	if (!netdev)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   988
		goto err_alloc_etherdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   989
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   990
	SET_NETDEV_DEV(netdev, &pdev->dev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   991
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   992
	pci_set_drvdata(pdev, netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   993
	adapter = netdev_priv(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   994
	adapter->netdev = netdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   995
	adapter->pdev = pdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   996
	adapter->msg_enable = (1 << debug) - 1;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   997
	adapter->bars = bars;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   998
	adapter->need_ioport = need_ioport;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   999
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1000
	hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1001
	hw->back = adapter;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1002
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1003
	err = -EIO;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1004
	hw->hw_addr = ioremap(pci_resource_start(pdev, BAR_0),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1005
			      pci_resource_len(pdev, BAR_0));
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1006
	if (!hw->hw_addr)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1007
		goto err_ioremap;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1008
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1009
	if (adapter->need_ioport) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1010
		for (i = BAR_1; i <= BAR_5; i++) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1011
			if (pci_resource_len(pdev, i) == 0)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1012
				continue;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1013
			if (pci_resource_flags(pdev, i) & IORESOURCE_IO) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1014
				hw->io_base = pci_resource_start(pdev, i);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1015
				break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1016
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1017
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1018
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1019
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1020
	netdev->open = &e1000_open;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1021
	netdev->stop = &e1000_close;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1022
	netdev->hard_start_xmit = &e1000_xmit_frame;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1023
	netdev->get_stats = &e1000_get_stats;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1024
	netdev->set_rx_mode = &e1000_set_rx_mode;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1025
	netdev->set_mac_address = &e1000_set_mac;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1026
	netdev->change_mtu = &e1000_change_mtu;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1027
	netdev->do_ioctl = &e1000_ioctl;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1028
	e1000_set_ethtool_ops(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1029
	netdev->tx_timeout = &e1000_tx_timeout;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1030
	netdev->watchdog_timeo = 5 * HZ;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1031
	netif_napi_add(netdev, &adapter->napi, e1000_clean, 64);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1032
	netdev->vlan_rx_register = e1000_vlan_rx_register;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1033
	netdev->vlan_rx_add_vid = e1000_vlan_rx_add_vid;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1034
	netdev->vlan_rx_kill_vid = e1000_vlan_rx_kill_vid;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1035
#ifdef CONFIG_NET_POLL_CONTROLLER
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1036
	netdev->poll_controller = e1000_netpoll;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1037
#endif
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1038
	strncpy(netdev->name, pci_name(pdev), sizeof(netdev->name) - 1);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1039
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1040
	adapter->bd_number = cards_found;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1041
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1042
	/* setup the private structure */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1043
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1044
	err = e1000_sw_init(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1045
	if (err)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1046
		goto err_sw_init;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1047
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1048
	err = -EIO;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1049
	/* Flash BAR mapping must happen after e1000_sw_init
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1050
	 * because it depends on mac_type */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1051
	if ((hw->mac_type == e1000_ich8lan) &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1052
	   (pci_resource_flags(pdev, 1) & IORESOURCE_MEM)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1053
		hw->flash_address =
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1054
			ioremap(pci_resource_start(pdev, 1),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1055
				pci_resource_len(pdev, 1));
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1056
		if (!hw->flash_address)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1057
			goto err_flashmap;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1058
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1059
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1060
	if (e1000_check_phy_reset_block(hw))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1061
		DPRINTK(PROBE, INFO, "PHY reset is blocked due to SOL/IDER session.\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1062
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1063
	if (hw->mac_type >= e1000_82543) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1064
		netdev->features = NETIF_F_SG |
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1065
				   NETIF_F_HW_CSUM |
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1066
				   NETIF_F_HW_VLAN_TX |
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1067
				   NETIF_F_HW_VLAN_RX |
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1068
				   NETIF_F_HW_VLAN_FILTER;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1069
		if (hw->mac_type == e1000_ich8lan)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1070
			netdev->features &= ~NETIF_F_HW_VLAN_FILTER;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1071
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1072
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1073
	if ((hw->mac_type >= e1000_82544) &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1074
	   (hw->mac_type != e1000_82547))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1075
		netdev->features |= NETIF_F_TSO;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1076
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1077
	if (hw->mac_type > e1000_82547_rev_2)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1078
		netdev->features |= NETIF_F_TSO6;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1079
	if (pci_using_dac)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1080
		netdev->features |= NETIF_F_HIGHDMA;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1081
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1082
	netdev->features |= NETIF_F_LLTX;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1083
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1084
	adapter->en_mng_pt = e1000_enable_mng_pass_thru(hw);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1085
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1086
	/* initialize eeprom parameters */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1087
	if (e1000_init_eeprom_params(hw)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1088
		E1000_ERR("EEPROM initialization failed\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1089
		goto err_eeprom;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1090
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1091
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1092
	/* before reading the EEPROM, reset the controller to
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1093
	 * put the device in a known good starting state */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1094
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1095
	e1000_reset_hw(hw);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1096
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1097
	/* make sure the EEPROM is good */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1098
	if (e1000_validate_eeprom_checksum(hw) < 0) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1099
		DPRINTK(PROBE, ERR, "The EEPROM Checksum Is Not Valid\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1100
		e1000_dump_eeprom(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1101
		/*
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1102
		 * set MAC address to all zeroes to invalidate and temporary
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1103
		 * disable this device for the user. This blocks regular
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1104
		 * traffic while still permitting ethtool ioctls from reaching
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1105
		 * the hardware as well as allowing the user to run the
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1106
		 * interface after manually setting a hw addr using
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1107
		 * `ip set address`
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1108
		 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1109
		memset(hw->mac_addr, 0, netdev->addr_len);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1110
	} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1111
		/* copy the MAC address out of the EEPROM */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1112
		if (e1000_read_mac_addr(hw))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1113
			DPRINTK(PROBE, ERR, "EEPROM Read Error\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1114
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1115
	/* don't block initalization here due to bad MAC address */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1116
	memcpy(netdev->dev_addr, hw->mac_addr, netdev->addr_len);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1117
	memcpy(netdev->perm_addr, hw->mac_addr, netdev->addr_len);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1118
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1119
	if (!is_valid_ether_addr(netdev->perm_addr))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1120
		DPRINTK(PROBE, ERR, "Invalid MAC Address\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1121
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1122
	e1000_get_bus_info(hw);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1123
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1124
	init_timer(&adapter->tx_fifo_stall_timer);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1125
	adapter->tx_fifo_stall_timer.function = &e1000_82547_tx_fifo_stall;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1126
	adapter->tx_fifo_stall_timer.data = (unsigned long)adapter;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1127
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1128
	init_timer(&adapter->watchdog_timer);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1129
	adapter->watchdog_timer.function = &e1000_watchdog;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1130
	adapter->watchdog_timer.data = (unsigned long) adapter;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1131
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1132
	init_timer(&adapter->phy_info_timer);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1133
	adapter->phy_info_timer.function = &e1000_update_phy_info;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1134
	adapter->phy_info_timer.data = (unsigned long)adapter;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1135
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1136
	INIT_WORK(&adapter->reset_task, e1000_reset_task);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1137
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1138
	e1000_check_options(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1139
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1140
	/* Initial Wake on LAN setting
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1141
	 * If APM wake is enabled in the EEPROM,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1142
	 * enable the ACPI Magic Packet filter
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1143
	 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1144
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1145
	switch (hw->mac_type) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1146
	case e1000_82542_rev2_0:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1147
	case e1000_82542_rev2_1:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1148
	case e1000_82543:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1149
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1150
	case e1000_82544:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1151
		e1000_read_eeprom(hw,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1152
			EEPROM_INIT_CONTROL2_REG, 1, &eeprom_data);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1153
		eeprom_apme_mask = E1000_EEPROM_82544_APM;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1154
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1155
	case e1000_ich8lan:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1156
		e1000_read_eeprom(hw,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1157
			EEPROM_INIT_CONTROL1_REG, 1, &eeprom_data);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1158
		eeprom_apme_mask = E1000_EEPROM_ICH8_APME;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1159
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1160
	case e1000_82546:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1161
	case e1000_82546_rev_3:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1162
	case e1000_82571:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1163
	case e1000_80003es2lan:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1164
		if (er32(STATUS) & E1000_STATUS_FUNC_1){
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1165
			e1000_read_eeprom(hw,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1166
				EEPROM_INIT_CONTROL3_PORT_B, 1, &eeprom_data);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1167
			break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1168
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1169
		/* Fall Through */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1170
	default:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1171
		e1000_read_eeprom(hw,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1172
			EEPROM_INIT_CONTROL3_PORT_A, 1, &eeprom_data);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1173
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1174
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1175
	if (eeprom_data & eeprom_apme_mask)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1176
		adapter->eeprom_wol |= E1000_WUFC_MAG;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1177
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1178
	/* now that we have the eeprom settings, apply the special cases
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1179
	 * where the eeprom may be wrong or the board simply won't support
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1180
	 * wake on lan on a particular port */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1181
	switch (pdev->device) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1182
	case E1000_DEV_ID_82546GB_PCIE:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1183
		adapter->eeprom_wol = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1184
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1185
	case E1000_DEV_ID_82546EB_FIBER:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1186
	case E1000_DEV_ID_82546GB_FIBER:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1187
	case E1000_DEV_ID_82571EB_FIBER:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1188
		/* Wake events only supported on port A for dual fiber
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1189
		 * regardless of eeprom setting */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1190
		if (er32(STATUS) & E1000_STATUS_FUNC_1)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1191
			adapter->eeprom_wol = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1192
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1193
	case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1194
	case E1000_DEV_ID_82571EB_QUAD_COPPER:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1195
	case E1000_DEV_ID_82571EB_QUAD_FIBER:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1196
	case E1000_DEV_ID_82571EB_QUAD_COPPER_LOWPROFILE:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1197
	case E1000_DEV_ID_82571PT_QUAD_COPPER:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1198
		/* if quad port adapter, disable WoL on all but port A */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1199
		if (global_quad_port_a != 0)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1200
			adapter->eeprom_wol = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1201
		else
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1202
			adapter->quad_port_a = 1;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1203
		/* Reset for multiple quad port adapters */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1204
		if (++global_quad_port_a == 4)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1205
			global_quad_port_a = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1206
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1207
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1208
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1209
	/* initialize the wol settings based on the eeprom settings */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1210
	adapter->wol = adapter->eeprom_wol;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1211
	device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1212
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1213
	/* print bus type/speed/width info */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1214
	DPRINTK(PROBE, INFO, "(PCI%s:%s:%s) ",
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1215
		((hw->bus_type == e1000_bus_type_pcix) ? "-X" :
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1216
		 (hw->bus_type == e1000_bus_type_pci_express ? " Express":"")),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1217
		((hw->bus_speed == e1000_bus_speed_2500) ? "2.5Gb/s" :
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1218
		 (hw->bus_speed == e1000_bus_speed_133) ? "133MHz" :
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1219
		 (hw->bus_speed == e1000_bus_speed_120) ? "120MHz" :
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1220
		 (hw->bus_speed == e1000_bus_speed_100) ? "100MHz" :
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1221
		 (hw->bus_speed == e1000_bus_speed_66) ? "66MHz" : "33MHz"),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1222
		((hw->bus_width == e1000_bus_width_64) ? "64-bit" :
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1223
		 (hw->bus_width == e1000_bus_width_pciex_4) ? "Width x4" :
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1224
		 (hw->bus_width == e1000_bus_width_pciex_1) ? "Width x1" :
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1225
		 "32-bit"));
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1226
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1227
	printk("%s\n", print_mac(mac, netdev->dev_addr));
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1228
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1229
	if (hw->bus_type == e1000_bus_type_pci_express) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1230
		DPRINTK(PROBE, WARNING, "This device (id %04x:%04x) will no "
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1231
			"longer be supported by this driver in the future.\n",
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1232
			pdev->vendor, pdev->device);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1233
		DPRINTK(PROBE, WARNING, "please use the \"e1000e\" "
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1234
			"driver instead.\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1235
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1236
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1237
	/* reset the hardware with the new settings */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1238
	e1000_reset(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1239
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1240
	/* If the controller is 82573 and f/w is AMT, do not set
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1241
	 * DRV_LOAD until the interface is up.  For all other cases,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1242
	 * let the f/w know that the h/w is now under the control
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1243
	 * of the driver. */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1244
	if (hw->mac_type != e1000_82573 ||
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1245
	    !e1000_check_mng_mode(hw))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1246
		e1000_get_hw_control(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1247
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1248
 	// offer device to EtherCAT master module
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1249
 	adapter->ecdev = ecdev_offer(netdev, ec_poll, THIS_MODULE);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1250
 	if (adapter->ecdev) {
2582
87e502828b3f Use return value of ecdev_open(); thanks to Patrick Bruenn.
Florian Pose <fp@igh-essen.com>
parents: 2471
diff changeset
  1251
		err = ecdev_open(adapter->ecdev);
87e502828b3f Use return value of ecdev_open(); thanks to Patrick Bruenn.
Florian Pose <fp@igh-essen.com>
parents: 2471
diff changeset
  1252
		if (err) {
1900
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1253
 			ecdev_withdraw(adapter->ecdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1254
 			goto err_register;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1255
 		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1256
 	} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1257
		/* tell the stack to leave us alone until e1000_open() is called */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1258
		netif_carrier_off(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1259
		netif_stop_queue(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1260
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1261
		strcpy(netdev->name, "eth%d");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1262
		err = register_netdev(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1263
		if (err)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1264
			goto err_register;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1265
 	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1266
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1267
	DPRINTK(PROBE, INFO, "Intel(R) PRO/1000 Network Connection\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1268
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1269
	cards_found++;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1270
	return 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1271
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1272
err_register:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1273
	e1000_release_hw_control(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1274
err_eeprom:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1275
	if (!e1000_check_phy_reset_block(hw))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1276
		e1000_phy_hw_reset(hw);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1277
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1278
	if (hw->flash_address)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1279
		iounmap(hw->flash_address);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1280
err_flashmap:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1281
	for (i = 0; i < adapter->num_rx_queues; i++)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1282
		dev_put(&adapter->polling_netdev[i]);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1283
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1284
	kfree(adapter->tx_ring);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1285
	kfree(adapter->rx_ring);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1286
	kfree(adapter->polling_netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1287
err_sw_init:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1288
	iounmap(hw->hw_addr);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1289
err_ioremap:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1290
	free_netdev(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1291
err_alloc_etherdev:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1292
	pci_release_selected_regions(pdev, bars);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1293
err_pci_reg:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1294
err_dma:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1295
	pci_disable_device(pdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1296
	return err;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1297
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1298
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1299
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1300
 * e1000_remove - Device Removal Routine
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1301
 * @pdev: PCI device information struct
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1302
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1303
 * e1000_remove is called by the PCI subsystem to alert the driver
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1304
 * that it should release a PCI device.  The could be caused by a
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1305
 * Hot-Plug event, or because the driver is going to be removed from
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1306
 * memory.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1307
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1308
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1309
static void __devexit e1000_remove(struct pci_dev *pdev)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1310
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1311
	struct net_device *netdev = pci_get_drvdata(pdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1312
	struct e1000_adapter *adapter = netdev_priv(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1313
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1314
	int i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1315
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1316
	cancel_work_sync(&adapter->reset_task);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1317
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1318
	e1000_release_manageability(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1319
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1320
	/* Release control of h/w to f/w.  If f/w is AMT enabled, this
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1321
	 * would have already happened in close and is redundant. */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1322
	e1000_release_hw_control(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1323
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1324
	for (i = 0; i < adapter->num_rx_queues; i++)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1325
		dev_put(&adapter->polling_netdev[i]);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1326
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1327
	if (adapter->ecdev) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1328
		ecdev_close(adapter->ecdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1329
		ecdev_withdraw(adapter->ecdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1330
	} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1331
		unregister_netdev(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1332
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1333
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1334
	if (!e1000_check_phy_reset_block(hw))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1335
		e1000_phy_hw_reset(hw);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1336
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1337
	kfree(adapter->tx_ring);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1338
	kfree(adapter->rx_ring);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1339
	kfree(adapter->polling_netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1340
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1341
	iounmap(hw->hw_addr);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1342
	if (hw->flash_address)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1343
		iounmap(hw->flash_address);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1344
	pci_release_selected_regions(pdev, adapter->bars);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1345
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1346
	free_netdev(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1347
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1348
	pci_disable_device(pdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1349
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1350
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1351
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1352
 * e1000_sw_init - Initialize general software structures (struct e1000_adapter)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1353
 * @adapter: board private structure to initialize
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1354
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1355
 * e1000_sw_init initializes the Adapter private data structure.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1356
 * Fields are initialized based on PCI device information and
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1357
 * OS network device settings (MTU size).
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1358
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1359
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1360
static int __devinit e1000_sw_init(struct e1000_adapter *adapter)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1361
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1362
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1363
	struct net_device *netdev = adapter->netdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1364
	struct pci_dev *pdev = adapter->pdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1365
	int i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1366
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1367
	/* PCI config space info */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1368
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1369
	hw->vendor_id = pdev->vendor;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1370
	hw->device_id = pdev->device;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1371
	hw->subsystem_vendor_id = pdev->subsystem_vendor;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1372
	hw->subsystem_id = pdev->subsystem_device;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1373
	hw->revision_id = pdev->revision;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1374
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1375
	pci_read_config_word(pdev, PCI_COMMAND, &hw->pci_cmd_word);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1376
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1377
	adapter->rx_buffer_len = MAXIMUM_ETHERNET_VLAN_SIZE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1378
	adapter->rx_ps_bsize0 = E1000_RXBUFFER_128;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1379
	hw->max_frame_size = netdev->mtu +
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1380
			     ENET_HEADER_SIZE + ETHERNET_FCS_SIZE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1381
	hw->min_frame_size = MINIMUM_ETHERNET_FRAME_SIZE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1382
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1383
	/* identify the MAC */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1384
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1385
	if (e1000_set_mac_type(hw)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1386
		DPRINTK(PROBE, ERR, "Unknown MAC Type\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1387
		return -EIO;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1388
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1389
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1390
	switch (hw->mac_type) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1391
	default:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1392
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1393
	case e1000_82541:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1394
	case e1000_82547:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1395
	case e1000_82541_rev_2:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1396
	case e1000_82547_rev_2:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1397
		hw->phy_init_script = 1;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1398
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1399
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1400
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1401
	e1000_set_media_type(hw);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1402
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1403
	hw->wait_autoneg_complete = false;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1404
	hw->tbi_compatibility_en = true;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1405
	hw->adaptive_ifs = true;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1406
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1407
	/* Copper options */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1408
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1409
	if (hw->media_type == e1000_media_type_copper) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1410
		hw->mdix = AUTO_ALL_MODES;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1411
		hw->disable_polarity_correction = false;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1412
		hw->master_slave = E1000_MASTER_SLAVE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1413
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1414
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1415
	adapter->num_tx_queues = 1;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1416
	adapter->num_rx_queues = 1;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1417
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1418
	if (e1000_alloc_queues(adapter)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1419
		DPRINTK(PROBE, ERR, "Unable to allocate memory for queues\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1420
		return -ENOMEM;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1421
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1422
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1423
	for (i = 0; i < adapter->num_rx_queues; i++) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1424
		adapter->polling_netdev[i].priv = adapter;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1425
		dev_hold(&adapter->polling_netdev[i]);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1426
		set_bit(__LINK_STATE_START, &adapter->polling_netdev[i].state);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1427
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1428
	spin_lock_init(&adapter->tx_queue_lock);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1429
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1430
	/* Explicitly disable IRQ since the NIC can be in any state. */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1431
	e1000_irq_disable(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1432
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1433
	spin_lock_init(&adapter->stats_lock);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1434
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1435
	set_bit(__E1000_DOWN, &adapter->flags);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1436
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1437
	return 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1438
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1439
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1440
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1441
 * e1000_alloc_queues - Allocate memory for all rings
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1442
 * @adapter: board private structure to initialize
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1443
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1444
 * We allocate one ring per queue at run-time since we don't know the
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1445
 * number of queues at compile-time.  The polling_netdev array is
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1446
 * intended for Multiqueue, but should work fine with a single queue.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1447
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1448
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1449
static int __devinit e1000_alloc_queues(struct e1000_adapter *adapter)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1450
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1451
	adapter->tx_ring = kcalloc(adapter->num_tx_queues,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1452
	                           sizeof(struct e1000_tx_ring), GFP_KERNEL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1453
	if (!adapter->tx_ring)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1454
		return -ENOMEM;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1455
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1456
	adapter->rx_ring = kcalloc(adapter->num_rx_queues,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1457
	                           sizeof(struct e1000_rx_ring), GFP_KERNEL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1458
	if (!adapter->rx_ring) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1459
		kfree(adapter->tx_ring);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1460
		return -ENOMEM;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1461
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1462
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1463
	adapter->polling_netdev = kcalloc(adapter->num_rx_queues,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1464
	                                  sizeof(struct net_device),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1465
	                                  GFP_KERNEL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1466
	if (!adapter->polling_netdev) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1467
		kfree(adapter->tx_ring);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1468
		kfree(adapter->rx_ring);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1469
		return -ENOMEM;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1470
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1471
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1472
	return E1000_SUCCESS;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1473
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1474
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1475
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1476
 * e1000_open - Called when a network interface is made active
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1477
 * @netdev: network interface device structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1478
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1479
 * Returns 0 on success, negative value on failure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1480
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1481
 * The open entry point is called when a network interface is made
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1482
 * active by the system (IFF_UP).  At this point all resources needed
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1483
 * for transmit and receive operations are allocated, the interrupt
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1484
 * handler is registered with the OS, the watchdog timer is started,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1485
 * and the stack is notified that the interface is ready.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1486
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1487
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1488
static int e1000_open(struct net_device *netdev)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1489
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1490
	struct e1000_adapter *adapter = netdev_priv(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1491
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1492
	int err;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1493
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1494
	/* disallow open during test */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1495
	if (test_bit(__E1000_TESTING, &adapter->flags))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1496
		return -EBUSY;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1497
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1498
	/* allocate transmit descriptors */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1499
	err = e1000_setup_all_tx_resources(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1500
	if (err)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1501
		goto err_setup_tx;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1502
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1503
	/* allocate receive descriptors */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1504
	err = e1000_setup_all_rx_resources(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1505
	if (err)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1506
		goto err_setup_rx;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1507
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1508
	e1000_power_up_phy(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1509
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1510
	adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1511
	if ((hw->mng_cookie.status &
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1512
			  E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1513
		e1000_update_mng_vlan(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1514
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1515
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1516
	/* If AMT is enabled, let the firmware know that the network
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1517
	 * interface is now open */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1518
	if (hw->mac_type == e1000_82573 &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1519
	    e1000_check_mng_mode(hw))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1520
		e1000_get_hw_control(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1521
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1522
	/* before we allocate an interrupt, we must be ready to handle it.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1523
	 * Setting DEBUG_SHIRQ in the kernel makes it fire an interrupt
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1524
	 * as soon as we call pci_request_irq, so we have to setup our
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1525
	 * clean_rx handler before we do so.  */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1526
	e1000_configure(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1527
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1528
	err = e1000_request_irq(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1529
	if (err)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1530
		goto err_req_irq;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1531
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1532
	/* From here on the code is the same as e1000_up() */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1533
	clear_bit(__E1000_DOWN, &adapter->flags);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1534
2469
634ba3b1eb95 Fixed possible segfault in e1000_open() function.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
  1535
	if (!adapter->ecdev) {
634ba3b1eb95 Fixed possible segfault in e1000_open() function.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
  1536
		napi_enable(&adapter->napi);
634ba3b1eb95 Fixed possible segfault in e1000_open() function.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
  1537
634ba3b1eb95 Fixed possible segfault in e1000_open() function.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
  1538
		e1000_irq_enable(adapter);
634ba3b1eb95 Fixed possible segfault in e1000_open() function.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
  1539
634ba3b1eb95 Fixed possible segfault in e1000_open() function.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
  1540
		netif_start_queue(netdev);
634ba3b1eb95 Fixed possible segfault in e1000_open() function.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
  1541
	}
1900
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1542
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1543
	/* fire a link status change interrupt to start the watchdog */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1544
	ew32(ICS, E1000_ICS_LSC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1545
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1546
	return E1000_SUCCESS;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1547
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1548
err_req_irq:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1549
	e1000_release_hw_control(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1550
	e1000_power_down_phy(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1551
	e1000_free_all_rx_resources(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1552
err_setup_rx:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1553
	e1000_free_all_tx_resources(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1554
err_setup_tx:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1555
	e1000_reset(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1556
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1557
	return err;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1558
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1559
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1560
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1561
 * e1000_close - Disables a network interface
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1562
 * @netdev: network interface device structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1563
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1564
 * Returns 0, this is not allowed to fail
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1565
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1566
 * The close entry point is called when an interface is de-activated
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1567
 * by the OS.  The hardware is still under the drivers control, but
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1568
 * needs to be disabled.  A global MAC reset is issued to stop the
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1569
 * hardware, and all transmit and receive resources are freed.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1570
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1571
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1572
static int e1000_close(struct net_device *netdev)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1573
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1574
	struct e1000_adapter *adapter = netdev_priv(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1575
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1576
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1577
	WARN_ON(test_bit(__E1000_RESETTING, &adapter->flags));
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1578
	e1000_down(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1579
	e1000_power_down_phy(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1580
	e1000_free_irq(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1581
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1582
	e1000_free_all_tx_resources(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1583
	e1000_free_all_rx_resources(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1584
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1585
	/* kill manageability vlan ID if supported, but not if a vlan with
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1586
	 * the same ID is registered on the host OS (let 8021q kill it) */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1587
	if ((hw->mng_cookie.status &
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1588
			  E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1589
	     !(adapter->vlgrp &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1590
	       vlan_group_get_device(adapter->vlgrp, adapter->mng_vlan_id))) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1591
		e1000_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1592
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1593
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1594
	/* If AMT is enabled, let the firmware know that the network
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1595
	 * interface is now closed */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1596
	if (hw->mac_type == e1000_82573 &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1597
	    e1000_check_mng_mode(hw))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1598
		e1000_release_hw_control(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1599
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1600
	return 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1601
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1602
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1603
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1604
 * e1000_check_64k_bound - check that memory doesn't cross 64kB boundary
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1605
 * @adapter: address of board private structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1606
 * @start: address of beginning of memory
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1607
 * @len: length of memory
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1608
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1609
static bool e1000_check_64k_bound(struct e1000_adapter *adapter, void *start,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1610
				  unsigned long len)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1611
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1612
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1613
	unsigned long begin = (unsigned long)start;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1614
	unsigned long end = begin + len;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1615
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1616
	/* First rev 82545 and 82546 need to not allow any memory
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1617
	 * write location to cross 64k boundary due to errata 23 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1618
	if (hw->mac_type == e1000_82545 ||
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1619
	    hw->mac_type == e1000_82546) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1620
		return ((begin ^ (end - 1)) >> 16) != 0 ? false : true;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1621
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1622
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1623
	return true;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1624
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1625
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1626
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1627
 * e1000_setup_tx_resources - allocate Tx resources (Descriptors)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1628
 * @adapter: board private structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1629
 * @txdr:    tx descriptor ring (for a specific queue) to setup
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1630
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1631
 * Return 0 on success, negative on failure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1632
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1633
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1634
static int e1000_setup_tx_resources(struct e1000_adapter *adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1635
				    struct e1000_tx_ring *txdr)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1636
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1637
	struct pci_dev *pdev = adapter->pdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1638
	int size;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1639
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1640
	size = sizeof(struct e1000_buffer) * txdr->count;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1641
	txdr->buffer_info = vmalloc(size);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1642
	if (!txdr->buffer_info) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1643
		DPRINTK(PROBE, ERR,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1644
		"Unable to allocate memory for the transmit descriptor ring\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1645
		return -ENOMEM;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1646
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1647
	memset(txdr->buffer_info, 0, size);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1648
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1649
	/* round up to nearest 4K */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1650
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1651
	txdr->size = txdr->count * sizeof(struct e1000_tx_desc);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1652
	txdr->size = ALIGN(txdr->size, 4096);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1653
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1654
	txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1655
	if (!txdr->desc) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1656
setup_tx_desc_die:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1657
		vfree(txdr->buffer_info);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1658
		DPRINTK(PROBE, ERR,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1659
		"Unable to allocate memory for the transmit descriptor ring\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1660
		return -ENOMEM;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1661
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1662
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1663
	/* Fix for errata 23, can't cross 64kB boundary */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1664
	if (!e1000_check_64k_bound(adapter, txdr->desc, txdr->size)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1665
		void *olddesc = txdr->desc;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1666
		dma_addr_t olddma = txdr->dma;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1667
		DPRINTK(TX_ERR, ERR, "txdr align check failed: %u bytes "
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1668
				     "at %p\n", txdr->size, txdr->desc);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1669
		/* Try again, without freeing the previous */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1670
		txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1671
		/* Failed allocation, critical failure */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1672
		if (!txdr->desc) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1673
			pci_free_consistent(pdev, txdr->size, olddesc, olddma);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1674
			goto setup_tx_desc_die;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1675
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1676
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1677
		if (!e1000_check_64k_bound(adapter, txdr->desc, txdr->size)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1678
			/* give up */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1679
			pci_free_consistent(pdev, txdr->size, txdr->desc,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1680
					    txdr->dma);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1681
			pci_free_consistent(pdev, txdr->size, olddesc, olddma);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1682
			DPRINTK(PROBE, ERR,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1683
				"Unable to allocate aligned memory "
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1684
				"for the transmit descriptor ring\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1685
			vfree(txdr->buffer_info);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1686
			return -ENOMEM;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1687
		} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1688
			/* Free old allocation, new allocation was successful */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1689
			pci_free_consistent(pdev, txdr->size, olddesc, olddma);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1690
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1691
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1692
	memset(txdr->desc, 0, txdr->size);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1693
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1694
	txdr->next_to_use = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1695
	txdr->next_to_clean = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1696
	spin_lock_init(&txdr->tx_lock);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1697
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1698
	return 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1699
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1700
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1701
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1702
 * e1000_setup_all_tx_resources - wrapper to allocate Tx resources
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1703
 * 				  (Descriptors) for all queues
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1704
 * @adapter: board private structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1705
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1706
 * Return 0 on success, negative on failure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1707
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1708
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1709
int e1000_setup_all_tx_resources(struct e1000_adapter *adapter)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1710
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1711
	int i, err = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1712
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1713
	for (i = 0; i < adapter->num_tx_queues; i++) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1714
		err = e1000_setup_tx_resources(adapter, &adapter->tx_ring[i]);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1715
		if (err) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1716
			DPRINTK(PROBE, ERR,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1717
				"Allocation for Tx Queue %u failed\n", i);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1718
			for (i-- ; i >= 0; i--)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1719
				e1000_free_tx_resources(adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1720
							&adapter->tx_ring[i]);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1721
			break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1722
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1723
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1724
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1725
	return err;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1726
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1727
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1728
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1729
 * e1000_configure_tx - Configure 8254x Transmit Unit after Reset
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1730
 * @adapter: board private structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1731
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1732
 * Configure the Tx unit of the MAC after a reset.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1733
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1734
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1735
static void e1000_configure_tx(struct e1000_adapter *adapter)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1736
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1737
	u64 tdba;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1738
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1739
	u32 tdlen, tctl, tipg, tarc;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1740
	u32 ipgr1, ipgr2;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1741
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1742
	/* Setup the HW Tx Head and Tail descriptor pointers */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1743
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1744
	switch (adapter->num_tx_queues) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1745
	case 1:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1746
	default:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1747
		tdba = adapter->tx_ring[0].dma;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1748
		tdlen = adapter->tx_ring[0].count *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1749
			sizeof(struct e1000_tx_desc);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1750
		ew32(TDLEN, tdlen);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1751
		ew32(TDBAH, (tdba >> 32));
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1752
		ew32(TDBAL, (tdba & 0x00000000ffffffffULL));
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1753
		ew32(TDT, 0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1754
		ew32(TDH, 0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1755
		adapter->tx_ring[0].tdh = ((hw->mac_type >= e1000_82543) ? E1000_TDH : E1000_82542_TDH);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1756
		adapter->tx_ring[0].tdt = ((hw->mac_type >= e1000_82543) ? E1000_TDT : E1000_82542_TDT);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1757
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1758
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1759
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1760
	/* Set the default values for the Tx Inter Packet Gap timer */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1761
	if (hw->mac_type <= e1000_82547_rev_2 &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1762
	    (hw->media_type == e1000_media_type_fiber ||
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1763
	     hw->media_type == e1000_media_type_internal_serdes))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1764
		tipg = DEFAULT_82543_TIPG_IPGT_FIBER;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1765
	else
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1766
		tipg = DEFAULT_82543_TIPG_IPGT_COPPER;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1767
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1768
	switch (hw->mac_type) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1769
	case e1000_82542_rev2_0:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1770
	case e1000_82542_rev2_1:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1771
		tipg = DEFAULT_82542_TIPG_IPGT;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1772
		ipgr1 = DEFAULT_82542_TIPG_IPGR1;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1773
		ipgr2 = DEFAULT_82542_TIPG_IPGR2;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1774
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1775
	case e1000_80003es2lan:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1776
		ipgr1 = DEFAULT_82543_TIPG_IPGR1;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1777
		ipgr2 = DEFAULT_80003ES2LAN_TIPG_IPGR2;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1778
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1779
	default:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1780
		ipgr1 = DEFAULT_82543_TIPG_IPGR1;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1781
		ipgr2 = DEFAULT_82543_TIPG_IPGR2;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1782
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1783
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1784
	tipg |= ipgr1 << E1000_TIPG_IPGR1_SHIFT;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1785
	tipg |= ipgr2 << E1000_TIPG_IPGR2_SHIFT;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1786
	ew32(TIPG, tipg);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1787
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1788
	/* Set the Tx Interrupt Delay register */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1789
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1790
	ew32(TIDV, adapter->tx_int_delay);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1791
	if (hw->mac_type >= e1000_82540)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1792
		ew32(TADV, adapter->tx_abs_int_delay);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1793
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1794
	/* Program the Transmit Control Register */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1795
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1796
	tctl = er32(TCTL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1797
	tctl &= ~E1000_TCTL_CT;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1798
	tctl |= E1000_TCTL_PSP | E1000_TCTL_RTLC |
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1799
		(E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1800
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1801
	if (hw->mac_type == e1000_82571 || hw->mac_type == e1000_82572) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1802
		tarc = er32(TARC0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1803
		/* set the speed mode bit, we'll clear it if we're not at
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1804
		 * gigabit link later */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1805
		tarc |= (1 << 21);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1806
		ew32(TARC0, tarc);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1807
	} else if (hw->mac_type == e1000_80003es2lan) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1808
		tarc = er32(TARC0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1809
		tarc |= 1;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1810
		ew32(TARC0, tarc);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1811
		tarc = er32(TARC1);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1812
		tarc |= 1;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1813
		ew32(TARC1, tarc);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1814
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1815
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1816
	e1000_config_collision_dist(hw);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1817
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1818
	/* Setup Transmit Descriptor Settings for eop descriptor */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1819
	adapter->txd_cmd = E1000_TXD_CMD_EOP | E1000_TXD_CMD_IFCS;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1820
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1821
	/* only set IDE if we are delaying interrupts using the timers */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1822
	if (adapter->tx_int_delay)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1823
		adapter->txd_cmd |= E1000_TXD_CMD_IDE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1824
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1825
	if (hw->mac_type < e1000_82543)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1826
		adapter->txd_cmd |= E1000_TXD_CMD_RPS;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1827
	else
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1828
		adapter->txd_cmd |= E1000_TXD_CMD_RS;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1829
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1830
	/* Cache if we're 82544 running in PCI-X because we'll
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1831
	 * need this to apply a workaround later in the send path. */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1832
	if (hw->mac_type == e1000_82544 &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1833
	    hw->bus_type == e1000_bus_type_pcix)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1834
		adapter->pcix_82544 = 1;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1835
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1836
	ew32(TCTL, tctl);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1837
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1838
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1839
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1840
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1841
 * e1000_setup_rx_resources - allocate Rx resources (Descriptors)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1842
 * @adapter: board private structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1843
 * @rxdr:    rx descriptor ring (for a specific queue) to setup
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1844
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1845
 * Returns 0 on success, negative on failure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1846
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1847
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1848
static int e1000_setup_rx_resources(struct e1000_adapter *adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1849
				    struct e1000_rx_ring *rxdr)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1850
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1851
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1852
	struct pci_dev *pdev = adapter->pdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1853
	int size, desc_len;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1854
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1855
	size = sizeof(struct e1000_buffer) * rxdr->count;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1856
	rxdr->buffer_info = vmalloc(size);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1857
	if (!rxdr->buffer_info) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1858
		DPRINTK(PROBE, ERR,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1859
		"Unable to allocate memory for the receive descriptor ring\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1860
		return -ENOMEM;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1861
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1862
	memset(rxdr->buffer_info, 0, size);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1863
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1864
	rxdr->ps_page = kcalloc(rxdr->count, sizeof(struct e1000_ps_page),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1865
	                        GFP_KERNEL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1866
	if (!rxdr->ps_page) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1867
		vfree(rxdr->buffer_info);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1868
		DPRINTK(PROBE, ERR,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1869
		"Unable to allocate memory for the receive descriptor ring\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1870
		return -ENOMEM;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1871
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1872
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1873
	rxdr->ps_page_dma = kcalloc(rxdr->count,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1874
	                            sizeof(struct e1000_ps_page_dma),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1875
	                            GFP_KERNEL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1876
	if (!rxdr->ps_page_dma) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1877
		vfree(rxdr->buffer_info);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1878
		kfree(rxdr->ps_page);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1879
		DPRINTK(PROBE, ERR,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1880
		"Unable to allocate memory for the receive descriptor ring\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1881
		return -ENOMEM;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1882
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1883
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1884
	if (hw->mac_type <= e1000_82547_rev_2)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1885
		desc_len = sizeof(struct e1000_rx_desc);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1886
	else
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1887
		desc_len = sizeof(union e1000_rx_desc_packet_split);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1888
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1889
	/* Round up to nearest 4K */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1890
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1891
	rxdr->size = rxdr->count * desc_len;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1892
	rxdr->size = ALIGN(rxdr->size, 4096);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1893
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1894
	rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1895
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1896
	if (!rxdr->desc) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1897
		DPRINTK(PROBE, ERR,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1898
		"Unable to allocate memory for the receive descriptor ring\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1899
setup_rx_desc_die:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1900
		vfree(rxdr->buffer_info);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1901
		kfree(rxdr->ps_page);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1902
		kfree(rxdr->ps_page_dma);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1903
		return -ENOMEM;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1904
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1905
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1906
	/* Fix for errata 23, can't cross 64kB boundary */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1907
	if (!e1000_check_64k_bound(adapter, rxdr->desc, rxdr->size)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1908
		void *olddesc = rxdr->desc;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1909
		dma_addr_t olddma = rxdr->dma;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1910
		DPRINTK(RX_ERR, ERR, "rxdr align check failed: %u bytes "
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1911
				     "at %p\n", rxdr->size, rxdr->desc);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1912
		/* Try again, without freeing the previous */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1913
		rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1914
		/* Failed allocation, critical failure */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1915
		if (!rxdr->desc) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1916
			pci_free_consistent(pdev, rxdr->size, olddesc, olddma);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1917
			DPRINTK(PROBE, ERR,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1918
				"Unable to allocate memory "
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1919
				"for the receive descriptor ring\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1920
			goto setup_rx_desc_die;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1921
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1922
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1923
		if (!e1000_check_64k_bound(adapter, rxdr->desc, rxdr->size)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1924
			/* give up */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1925
			pci_free_consistent(pdev, rxdr->size, rxdr->desc,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1926
					    rxdr->dma);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1927
			pci_free_consistent(pdev, rxdr->size, olddesc, olddma);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1928
			DPRINTK(PROBE, ERR,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1929
				"Unable to allocate aligned memory "
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1930
				"for the receive descriptor ring\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1931
			goto setup_rx_desc_die;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1932
		} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1933
			/* Free old allocation, new allocation was successful */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1934
			pci_free_consistent(pdev, rxdr->size, olddesc, olddma);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1935
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1936
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1937
	memset(rxdr->desc, 0, rxdr->size);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1938
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1939
	rxdr->next_to_clean = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1940
	rxdr->next_to_use = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1941
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1942
	return 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1943
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1944
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1945
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1946
 * e1000_setup_all_rx_resources - wrapper to allocate Rx resources
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1947
 * 				  (Descriptors) for all queues
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1948
 * @adapter: board private structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1949
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1950
 * Return 0 on success, negative on failure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1951
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1952
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1953
int e1000_setup_all_rx_resources(struct e1000_adapter *adapter)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1954
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1955
	int i, err = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1956
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1957
	for (i = 0; i < adapter->num_rx_queues; i++) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1958
		err = e1000_setup_rx_resources(adapter, &adapter->rx_ring[i]);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1959
		if (err) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1960
			DPRINTK(PROBE, ERR,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1961
				"Allocation for Rx Queue %u failed\n", i);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1962
			for (i-- ; i >= 0; i--)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1963
				e1000_free_rx_resources(adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1964
							&adapter->rx_ring[i]);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1965
			break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1966
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1967
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1968
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1969
	return err;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1970
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1971
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1972
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1973
 * e1000_setup_rctl - configure the receive control registers
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1974
 * @adapter: Board private structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1975
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1976
#define PAGE_USE_COUNT(S) (((S) >> PAGE_SHIFT) + \
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1977
			(((S) & (PAGE_SIZE - 1)) ? 1 : 0))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1978
static void e1000_setup_rctl(struct e1000_adapter *adapter)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1979
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1980
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1981
	u32 rctl, rfctl;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1982
	u32 psrctl = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1983
#ifndef CONFIG_E1000_DISABLE_PACKET_SPLIT
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1984
	u32 pages = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1985
#endif
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1986
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1987
	rctl = er32(RCTL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1988
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1989
	rctl &= ~(3 << E1000_RCTL_MO_SHIFT);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1990
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1991
	rctl |= E1000_RCTL_EN | E1000_RCTL_BAM |
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1992
		E1000_RCTL_LBM_NO | E1000_RCTL_RDMTS_HALF |
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1993
		(hw->mc_filter_type << E1000_RCTL_MO_SHIFT);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1994
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1995
	if (hw->tbi_compatibility_on == 1)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1996
		rctl |= E1000_RCTL_SBP;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1997
	else
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1998
		rctl &= ~E1000_RCTL_SBP;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1999
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2000
	if (adapter->netdev->mtu <= ETH_DATA_LEN)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2001
		rctl &= ~E1000_RCTL_LPE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2002
	else
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2003
		rctl |= E1000_RCTL_LPE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2004
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2005
	/* Setup buffer sizes */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2006
	rctl &= ~E1000_RCTL_SZ_4096;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2007
	rctl |= E1000_RCTL_BSEX;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2008
	switch (adapter->rx_buffer_len) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2009
		case E1000_RXBUFFER_256:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2010
			rctl |= E1000_RCTL_SZ_256;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2011
			rctl &= ~E1000_RCTL_BSEX;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2012
			break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2013
		case E1000_RXBUFFER_512:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2014
			rctl |= E1000_RCTL_SZ_512;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2015
			rctl &= ~E1000_RCTL_BSEX;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2016
			break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2017
		case E1000_RXBUFFER_1024:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2018
			rctl |= E1000_RCTL_SZ_1024;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2019
			rctl &= ~E1000_RCTL_BSEX;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2020
			break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2021
		case E1000_RXBUFFER_2048:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2022
		default:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2023
			rctl |= E1000_RCTL_SZ_2048;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2024
			rctl &= ~E1000_RCTL_BSEX;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2025
			break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2026
		case E1000_RXBUFFER_4096:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2027
			rctl |= E1000_RCTL_SZ_4096;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2028
			break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2029
		case E1000_RXBUFFER_8192:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2030
			rctl |= E1000_RCTL_SZ_8192;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2031
			break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2032
		case E1000_RXBUFFER_16384:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2033
			rctl |= E1000_RCTL_SZ_16384;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2034
			break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2035
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2036
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2037
#ifndef CONFIG_E1000_DISABLE_PACKET_SPLIT
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2038
	/* 82571 and greater support packet-split where the protocol
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2039
	 * header is placed in skb->data and the packet data is
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2040
	 * placed in pages hanging off of skb_shinfo(skb)->nr_frags.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2041
	 * In the case of a non-split, skb->data is linearly filled,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2042
	 * followed by the page buffers.  Therefore, skb->data is
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2043
	 * sized to hold the largest protocol header.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2044
	 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2045
	/* allocations using alloc_page take too long for regular MTU
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2046
	 * so only enable packet split for jumbo frames */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2047
	pages = PAGE_USE_COUNT(adapter->netdev->mtu);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2048
	if ((hw->mac_type >= e1000_82571) && (pages <= 3) &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2049
	    PAGE_SIZE <= 16384 && (rctl & E1000_RCTL_LPE))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2050
		adapter->rx_ps_pages = pages;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2051
	else
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2052
		adapter->rx_ps_pages = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2053
#endif
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2054
	if (adapter->rx_ps_pages) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2055
		/* Configure extra packet-split registers */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2056
		rfctl = er32(RFCTL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2057
		rfctl |= E1000_RFCTL_EXTEN;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2058
		/* disable packet split support for IPv6 extension headers,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2059
		 * because some malformed IPv6 headers can hang the RX */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2060
		rfctl |= (E1000_RFCTL_IPV6_EX_DIS |
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2061
		          E1000_RFCTL_NEW_IPV6_EXT_DIS);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2062
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2063
		ew32(RFCTL, rfctl);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2064
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2065
		rctl |= E1000_RCTL_DTYP_PS;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2066
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2067
		psrctl |= adapter->rx_ps_bsize0 >>
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2068
			E1000_PSRCTL_BSIZE0_SHIFT;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2069
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2070
		switch (adapter->rx_ps_pages) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2071
		case 3:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2072
			psrctl |= PAGE_SIZE <<
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2073
				E1000_PSRCTL_BSIZE3_SHIFT;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2074
		case 2:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2075
			psrctl |= PAGE_SIZE <<
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2076
				E1000_PSRCTL_BSIZE2_SHIFT;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2077
		case 1:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2078
			psrctl |= PAGE_SIZE >>
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2079
				E1000_PSRCTL_BSIZE1_SHIFT;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2080
			break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2081
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2082
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2083
		ew32(PSRCTL, psrctl);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2084
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2085
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2086
	ew32(RCTL, rctl);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2087
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2088
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2089
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2090
 * e1000_configure_rx - Configure 8254x Receive Unit after Reset
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2091
 * @adapter: board private structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2092
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2093
 * Configure the Rx unit of the MAC after a reset.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2094
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2095
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2096
static void e1000_configure_rx(struct e1000_adapter *adapter)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2097
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2098
	u64 rdba;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2099
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2100
	u32 rdlen, rctl, rxcsum, ctrl_ext;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2101
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2102
	if (adapter->rx_ps_pages) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2103
		/* this is a 32 byte descriptor */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2104
		rdlen = adapter->rx_ring[0].count *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2105
			sizeof(union e1000_rx_desc_packet_split);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2106
		adapter->clean_rx = e1000_clean_rx_irq_ps;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2107
		adapter->alloc_rx_buf = e1000_alloc_rx_buffers_ps;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2108
	} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2109
		rdlen = adapter->rx_ring[0].count *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2110
			sizeof(struct e1000_rx_desc);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2111
		adapter->clean_rx = e1000_clean_rx_irq;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2112
		adapter->alloc_rx_buf = e1000_alloc_rx_buffers;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2113
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2114
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2115
	/* disable receives while setting up the descriptors */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2116
	rctl = er32(RCTL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2117
	ew32(RCTL, rctl & ~E1000_RCTL_EN);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2118
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2119
	/* set the Receive Delay Timer Register */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2120
	ew32(RDTR, adapter->rx_int_delay);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2121
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2122
	if (hw->mac_type >= e1000_82540) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2123
		ew32(RADV, adapter->rx_abs_int_delay);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2124
		if (adapter->itr_setting != 0)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2125
			ew32(ITR, 1000000000 / (adapter->itr * 256));
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2126
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2127
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2128
	if (hw->mac_type >= e1000_82571) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2129
		ctrl_ext = er32(CTRL_EXT);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2130
		/* Reset delay timers after every interrupt */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2131
		ctrl_ext |= E1000_CTRL_EXT_INT_TIMER_CLR;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2132
		/* Auto-Mask interrupts upon ICR access */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2133
		ctrl_ext |= E1000_CTRL_EXT_IAME;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2134
		ew32(IAM, 0xffffffff);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2135
		ew32(CTRL_EXT, ctrl_ext);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2136
		E1000_WRITE_FLUSH();
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2137
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2138
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2139
	/* Setup the HW Rx Head and Tail Descriptor Pointers and
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2140
	 * the Base and Length of the Rx Descriptor Ring */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2141
	switch (adapter->num_rx_queues) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2142
	case 1:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2143
	default:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2144
		rdba = adapter->rx_ring[0].dma;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2145
		ew32(RDLEN, rdlen);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2146
		ew32(RDBAH, (rdba >> 32));
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2147
		ew32(RDBAL, (rdba & 0x00000000ffffffffULL));
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2148
		ew32(RDT, 0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2149
		ew32(RDH, 0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2150
		adapter->rx_ring[0].rdh = ((hw->mac_type >= e1000_82543) ? E1000_RDH : E1000_82542_RDH);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2151
		adapter->rx_ring[0].rdt = ((hw->mac_type >= e1000_82543) ? E1000_RDT : E1000_82542_RDT);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2152
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2153
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2154
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2155
	/* Enable 82543 Receive Checksum Offload for TCP and UDP */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2156
	if (hw->mac_type >= e1000_82543) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2157
		rxcsum = er32(RXCSUM);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2158
		if (adapter->rx_csum) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2159
			rxcsum |= E1000_RXCSUM_TUOFL;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2160
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2161
			/* Enable 82571 IPv4 payload checksum for UDP fragments
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2162
			 * Must be used in conjunction with packet-split. */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2163
			if ((hw->mac_type >= e1000_82571) &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2164
			    (adapter->rx_ps_pages)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2165
				rxcsum |= E1000_RXCSUM_IPPCSE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2166
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2167
		} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2168
			rxcsum &= ~E1000_RXCSUM_TUOFL;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2169
			/* don't need to clear IPPCSE as it defaults to 0 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2170
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2171
		ew32(RXCSUM, rxcsum);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2172
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2173
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2174
	/* enable early receives on 82573, only takes effect if using > 2048
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2175
	 * byte total frame size.  for example only for jumbo frames */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2176
#define E1000_ERT_2048 0x100
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2177
	if (hw->mac_type == e1000_82573)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2178
		ew32(ERT, E1000_ERT_2048);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2179
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2180
	/* Enable Receives */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2181
	ew32(RCTL, rctl);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2182
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2183
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2184
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2185
 * e1000_free_tx_resources - Free Tx Resources per Queue
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2186
 * @adapter: board private structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2187
 * @tx_ring: Tx descriptor ring for a specific queue
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2188
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2189
 * Free all transmit software resources
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2190
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2191
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2192
static void e1000_free_tx_resources(struct e1000_adapter *adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2193
				    struct e1000_tx_ring *tx_ring)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2194
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2195
	struct pci_dev *pdev = adapter->pdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2196
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2197
	e1000_clean_tx_ring(adapter, tx_ring);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2198
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2199
	vfree(tx_ring->buffer_info);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2200
	tx_ring->buffer_info = NULL;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2201
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2202
	pci_free_consistent(pdev, tx_ring->size, tx_ring->desc, tx_ring->dma);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2203
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2204
	tx_ring->desc = NULL;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2205
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2206
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2207
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2208
 * e1000_free_all_tx_resources - Free Tx Resources for All Queues
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2209
 * @adapter: board private structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2210
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2211
 * Free all transmit software resources
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2212
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2213
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2214
void e1000_free_all_tx_resources(struct e1000_adapter *adapter)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2215
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2216
	int i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2217
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2218
	for (i = 0; i < adapter->num_tx_queues; i++)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2219
		e1000_free_tx_resources(adapter, &adapter->tx_ring[i]);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2220
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2221
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2222
static void e1000_unmap_and_free_tx_resource(struct e1000_adapter *adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2223
					     struct e1000_buffer *buffer_info)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2224
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2225
	if (adapter->ecdev)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2226
		return;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2227
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2228
	if (buffer_info->dma) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2229
		pci_unmap_page(adapter->pdev,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2230
				buffer_info->dma,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2231
				buffer_info->length,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2232
				PCI_DMA_TODEVICE);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2233
		buffer_info->dma = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2234
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2235
	if (buffer_info->skb) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2236
		dev_kfree_skb_any(buffer_info->skb);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2237
		buffer_info->skb = NULL;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2238
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2239
	/* buffer_info must be completely set up in the transmit path */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2240
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2241
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2242
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2243
 * e1000_clean_tx_ring - Free Tx Buffers
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2244
 * @adapter: board private structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2245
 * @tx_ring: ring to be cleaned
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2246
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2247
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2248
static void e1000_clean_tx_ring(struct e1000_adapter *adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2249
				struct e1000_tx_ring *tx_ring)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2250
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2251
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2252
	struct e1000_buffer *buffer_info;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2253
	unsigned long size;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2254
	unsigned int i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2255
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2256
	/* Free all the Tx ring sk_buffs */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2257
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2258
	for (i = 0; i < tx_ring->count; i++) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2259
		buffer_info = &tx_ring->buffer_info[i];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2260
		e1000_unmap_and_free_tx_resource(adapter, buffer_info);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2261
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2262
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2263
	size = sizeof(struct e1000_buffer) * tx_ring->count;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2264
	memset(tx_ring->buffer_info, 0, size);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2265
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2266
	/* Zero out the descriptor ring */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2267
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2268
	memset(tx_ring->desc, 0, tx_ring->size);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2269
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2270
	tx_ring->next_to_use = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2271
	tx_ring->next_to_clean = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2272
	tx_ring->last_tx_tso = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2273
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2274
	writel(0, hw->hw_addr + tx_ring->tdh);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2275
	writel(0, hw->hw_addr + tx_ring->tdt);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2276
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2277
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2278
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2279
 * e1000_clean_all_tx_rings - Free Tx Buffers for all queues
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2280
 * @adapter: board private structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2281
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2282
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2283
static void e1000_clean_all_tx_rings(struct e1000_adapter *adapter)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2284
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2285
	int i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2286
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2287
	for (i = 0; i < adapter->num_tx_queues; i++)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2288
		e1000_clean_tx_ring(adapter, &adapter->tx_ring[i]);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2289
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2290
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2291
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2292
 * e1000_free_rx_resources - Free Rx Resources
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2293
 * @adapter: board private structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2294
 * @rx_ring: ring to clean the resources from
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2295
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2296
 * Free all receive software resources
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2297
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2298
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2299
static void e1000_free_rx_resources(struct e1000_adapter *adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2300
				    struct e1000_rx_ring *rx_ring)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2301
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2302
	struct pci_dev *pdev = adapter->pdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2303
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2304
	e1000_clean_rx_ring(adapter, rx_ring);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2305
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2306
	vfree(rx_ring->buffer_info);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2307
	rx_ring->buffer_info = NULL;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2308
	kfree(rx_ring->ps_page);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2309
	rx_ring->ps_page = NULL;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2310
	kfree(rx_ring->ps_page_dma);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2311
	rx_ring->ps_page_dma = NULL;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2312
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2313
	pci_free_consistent(pdev, rx_ring->size, rx_ring->desc, rx_ring->dma);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2314
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2315
	rx_ring->desc = NULL;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2316
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2317
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2318
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2319
 * e1000_free_all_rx_resources - Free Rx Resources for All Queues
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2320
 * @adapter: board private structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2321
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2322
 * Free all receive software resources
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2323
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2324
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2325
void e1000_free_all_rx_resources(struct e1000_adapter *adapter)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2326
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2327
	int i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2328
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2329
	for (i = 0; i < adapter->num_rx_queues; i++)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2330
		e1000_free_rx_resources(adapter, &adapter->rx_ring[i]);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2331
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2332
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2333
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2334
 * e1000_clean_rx_ring - Free Rx Buffers per Queue
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2335
 * @adapter: board private structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2336
 * @rx_ring: ring to free buffers from
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2337
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2338
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2339
static void e1000_clean_rx_ring(struct e1000_adapter *adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2340
				struct e1000_rx_ring *rx_ring)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2341
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2342
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2343
	struct e1000_buffer *buffer_info;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2344
	struct e1000_ps_page *ps_page;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2345
	struct e1000_ps_page_dma *ps_page_dma;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2346
	struct pci_dev *pdev = adapter->pdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2347
	unsigned long size;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2348
	unsigned int i, j;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2349
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2350
	/* Free all the Rx ring sk_buffs */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2351
	for (i = 0; i < rx_ring->count; i++) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2352
		buffer_info = &rx_ring->buffer_info[i];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2353
		if (buffer_info->skb) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2354
			pci_unmap_single(pdev,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2355
					 buffer_info->dma,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2356
					 buffer_info->length,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2357
					 PCI_DMA_FROMDEVICE);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2358
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2359
			dev_kfree_skb(buffer_info->skb);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2360
			buffer_info->skb = NULL;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2361
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2362
		ps_page = &rx_ring->ps_page[i];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2363
		ps_page_dma = &rx_ring->ps_page_dma[i];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2364
		for (j = 0; j < adapter->rx_ps_pages; j++) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2365
			if (!ps_page->ps_page[j]) break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2366
			pci_unmap_page(pdev,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2367
				       ps_page_dma->ps_page_dma[j],
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2368
				       PAGE_SIZE, PCI_DMA_FROMDEVICE);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2369
			ps_page_dma->ps_page_dma[j] = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2370
			put_page(ps_page->ps_page[j]);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2371
			ps_page->ps_page[j] = NULL;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2372
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2373
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2374
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2375
	size = sizeof(struct e1000_buffer) * rx_ring->count;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2376
	memset(rx_ring->buffer_info, 0, size);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2377
	size = sizeof(struct e1000_ps_page) * rx_ring->count;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2378
	memset(rx_ring->ps_page, 0, size);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2379
	size = sizeof(struct e1000_ps_page_dma) * rx_ring->count;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2380
	memset(rx_ring->ps_page_dma, 0, size);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2381
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2382
	/* Zero out the descriptor ring */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2383
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2384
	memset(rx_ring->desc, 0, rx_ring->size);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2385
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2386
	rx_ring->next_to_clean = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2387
	rx_ring->next_to_use = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2388
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2389
	writel(0, hw->hw_addr + rx_ring->rdh);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2390
	writel(0, hw->hw_addr + rx_ring->rdt);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2391
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2392
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2393
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2394
 * e1000_clean_all_rx_rings - Free Rx Buffers for all queues
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2395
 * @adapter: board private structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2396
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2397
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2398
static void e1000_clean_all_rx_rings(struct e1000_adapter *adapter)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2399
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2400
	int i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2401
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2402
	for (i = 0; i < adapter->num_rx_queues; i++)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2403
		e1000_clean_rx_ring(adapter, &adapter->rx_ring[i]);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2404
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2405
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2406
/* The 82542 2.0 (revision 2) needs to have the receive unit in reset
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2407
 * and memory write and invalidate disabled for certain operations
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2408
 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2409
static void e1000_enter_82542_rst(struct e1000_adapter *adapter)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2410
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2411
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2412
	struct net_device *netdev = adapter->netdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2413
	u32 rctl;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2414
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2415
	e1000_pci_clear_mwi(hw);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2416
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2417
	rctl = er32(RCTL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2418
	rctl |= E1000_RCTL_RST;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2419
	ew32(RCTL, rctl);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2420
	E1000_WRITE_FLUSH();
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2421
	mdelay(5);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2422
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2423
	if (!adapter->ecdev && netif_running(netdev))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2424
		e1000_clean_all_rx_rings(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2425
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2426
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2427
static void e1000_leave_82542_rst(struct e1000_adapter *adapter)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2428
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2429
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2430
	struct net_device *netdev = adapter->netdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2431
	u32 rctl;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2432
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2433
	rctl = er32(RCTL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2434
	rctl &= ~E1000_RCTL_RST;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2435
	ew32(RCTL, rctl);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2436
	E1000_WRITE_FLUSH();
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2437
	mdelay(5);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2438
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2439
	if (hw->pci_cmd_word & PCI_COMMAND_INVALIDATE)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2440
		e1000_pci_set_mwi(hw);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2441
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2442
	if (!adapter->netdev && netif_running(netdev)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2443
		/* No need to loop, because 82542 supports only 1 queue */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2444
		struct e1000_rx_ring *ring = &adapter->rx_ring[0];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2445
		e1000_configure_rx(adapter);
2421
bc2d4bf9cbe5 Removed trailing spaces.
Florian Pose <fp@igh-essen.com>
parents: 2252
diff changeset
  2446
		if (adapter->ecdev) {
1900
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2447
			/* fill rx ring completely! */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2448
			adapter->alloc_rx_buf(adapter, ring, ring->count);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2449
		} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2450
            /* this one leaves the last ring element unallocated! */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2451
			adapter->alloc_rx_buf(adapter, ring, E1000_DESC_UNUSED(ring));
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2452
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2453
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2454
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2455
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2456
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2457
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2458
 * e1000_set_mac - Change the Ethernet Address of the NIC
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2459
 * @netdev: network interface device structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2460
 * @p: pointer to an address structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2461
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2462
 * Returns 0 on success, negative on failure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2463
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2464
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2465
static int e1000_set_mac(struct net_device *netdev, void *p)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2466
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2467
	struct e1000_adapter *adapter = netdev_priv(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2468
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2469
	struct sockaddr *addr = p;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2470
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2471
	if (!is_valid_ether_addr(addr->sa_data))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2472
		return -EADDRNOTAVAIL;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2473
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2474
	/* 82542 2.0 needs to be in reset to write receive address registers */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2475
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2476
	if (hw->mac_type == e1000_82542_rev2_0)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2477
		e1000_enter_82542_rst(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2478
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2479
	memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2480
	memcpy(hw->mac_addr, addr->sa_data, netdev->addr_len);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2481
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2482
	e1000_rar_set(hw, hw->mac_addr, 0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2483
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2484
	/* With 82571 controllers, LAA may be overwritten (with the default)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2485
	 * due to controller reset from the other port. */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2486
	if (hw->mac_type == e1000_82571) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2487
		/* activate the work around */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2488
		hw->laa_is_present = 1;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2489
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2490
		/* Hold a copy of the LAA in RAR[14] This is done so that
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2491
		 * between the time RAR[0] gets clobbered  and the time it
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2492
		 * gets fixed (in e1000_watchdog), the actual LAA is in one
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2493
		 * of the RARs and no incoming packets directed to this port
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2494
		 * are dropped. Eventaully the LAA will be in RAR[0] and
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2495
		 * RAR[14] */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2496
		e1000_rar_set(hw, hw->mac_addr,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2497
					E1000_RAR_ENTRIES - 1);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2498
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2499
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2500
	if (hw->mac_type == e1000_82542_rev2_0)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2501
		e1000_leave_82542_rst(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2502
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2503
	return 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2504
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2505
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2506
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2507
 * e1000_set_rx_mode - Secondary Unicast, Multicast and Promiscuous mode set
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2508
 * @netdev: network interface device structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2509
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2510
 * The set_rx_mode entry point is called whenever the unicast or multicast
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2511
 * address lists or the network interface flags are updated. This routine is
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2512
 * responsible for configuring the hardware for proper unicast, multicast,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2513
 * promiscuous mode, and all-multi behavior.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2514
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2515
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2516
static void e1000_set_rx_mode(struct net_device *netdev)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2517
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2518
	struct e1000_adapter *adapter = netdev_priv(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2519
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2520
	struct dev_addr_list *uc_ptr;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2521
	struct dev_addr_list *mc_ptr;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2522
	u32 rctl;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2523
	u32 hash_value;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2524
	int i, rar_entries = E1000_RAR_ENTRIES;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2525
	int mta_reg_count = (hw->mac_type == e1000_ich8lan) ?
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2526
				E1000_NUM_MTA_REGISTERS_ICH8LAN :
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2527
				E1000_NUM_MTA_REGISTERS;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2528
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2529
	if (hw->mac_type == e1000_ich8lan)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2530
		rar_entries = E1000_RAR_ENTRIES_ICH8LAN;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2531
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2532
	/* reserve RAR[14] for LAA over-write work-around */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2533
	if (hw->mac_type == e1000_82571)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2534
		rar_entries--;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2535
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2536
	/* Check for Promiscuous and All Multicast modes */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2537
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2538
	rctl = er32(RCTL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2539
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2540
	if (netdev->flags & IFF_PROMISC) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2541
		rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2542
		rctl &= ~E1000_RCTL_VFE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2543
	} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2544
		if (netdev->flags & IFF_ALLMULTI) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2545
			rctl |= E1000_RCTL_MPE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2546
		} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2547
			rctl &= ~E1000_RCTL_MPE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2548
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2549
		if (adapter->hw.mac_type != e1000_ich8lan)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2550
			rctl |= E1000_RCTL_VFE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2551
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2552
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2553
	uc_ptr = NULL;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2554
	if (netdev->uc_count > rar_entries - 1) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2555
		rctl |= E1000_RCTL_UPE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2556
	} else if (!(netdev->flags & IFF_PROMISC)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2557
		rctl &= ~E1000_RCTL_UPE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2558
		uc_ptr = netdev->uc_list;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2559
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2560
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2561
	ew32(RCTL, rctl);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2562
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2563
	/* 82542 2.0 needs to be in reset to write receive address registers */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2564
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2565
	if (hw->mac_type == e1000_82542_rev2_0)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2566
		e1000_enter_82542_rst(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2567
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2568
	/* load the first 14 addresses into the exact filters 1-14. Unicast
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2569
	 * addresses take precedence to avoid disabling unicast filtering
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2570
	 * when possible.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2571
	 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2572
	 * RAR 0 is used for the station MAC adddress
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2573
	 * if there are not 14 addresses, go ahead and clear the filters
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2574
	 * -- with 82571 controllers only 0-13 entries are filled here
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2575
	 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2576
	mc_ptr = netdev->mc_list;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2577
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2578
	for (i = 1; i < rar_entries; i++) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2579
		if (uc_ptr) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2580
			e1000_rar_set(hw, uc_ptr->da_addr, i);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2581
			uc_ptr = uc_ptr->next;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2582
		} else if (mc_ptr) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2583
			e1000_rar_set(hw, mc_ptr->da_addr, i);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2584
			mc_ptr = mc_ptr->next;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2585
		} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2586
			E1000_WRITE_REG_ARRAY(hw, RA, i << 1, 0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2587
			E1000_WRITE_FLUSH();
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2588
			E1000_WRITE_REG_ARRAY(hw, RA, (i << 1) + 1, 0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2589
			E1000_WRITE_FLUSH();
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2590
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2591
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2592
	WARN_ON(uc_ptr != NULL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2593
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2594
	/* clear the old settings from the multicast hash table */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2595
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2596
	for (i = 0; i < mta_reg_count; i++) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2597
		E1000_WRITE_REG_ARRAY(hw, MTA, i, 0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2598
		E1000_WRITE_FLUSH();
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2599
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2600
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2601
	/* load any remaining addresses into the hash table */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2602
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2603
	for (; mc_ptr; mc_ptr = mc_ptr->next) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2604
		hash_value = e1000_hash_mc_addr(hw, mc_ptr->da_addr);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2605
		e1000_mta_set(hw, hash_value);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2606
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2607
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2608
	if (hw->mac_type == e1000_82542_rev2_0)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2609
		e1000_leave_82542_rst(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2610
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2611
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2612
/* Need to wait a few seconds after link up to get diagnostic information from
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2613
 * the phy */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2614
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2615
static void e1000_update_phy_info(unsigned long data)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2616
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2617
	struct e1000_adapter *adapter = (struct e1000_adapter *)data;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2618
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2619
	e1000_phy_get_info(hw, &adapter->phy_info);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2620
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2621
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2622
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2623
 * e1000_82547_tx_fifo_stall - Timer Call-back
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2624
 * @data: pointer to adapter cast into an unsigned long
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2625
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2626
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2627
static void e1000_82547_tx_fifo_stall(unsigned long data)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2628
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2629
	struct e1000_adapter *adapter = (struct e1000_adapter *)data;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2630
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2631
	struct net_device *netdev = adapter->netdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2632
	u32 tctl;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2633
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2634
	if (atomic_read(&adapter->tx_fifo_stall)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2635
		if ((er32(TDT) == er32(TDH)) &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2636
		   (er32(TDFT) == er32(TDFH)) &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2637
		   (er32(TDFTS) == er32(TDFHS))) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2638
			tctl = er32(TCTL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2639
			ew32(TCTL, tctl & ~E1000_TCTL_EN);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2640
			ew32(TDFT, adapter->tx_head_addr);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2641
			ew32(TDFH, adapter->tx_head_addr);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2642
			ew32(TDFTS, adapter->tx_head_addr);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2643
			ew32(TDFHS, adapter->tx_head_addr);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2644
			ew32(TCTL, tctl);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2645
			E1000_WRITE_FLUSH();
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2646
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2647
			adapter->tx_fifo_head = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2648
			atomic_set(&adapter->tx_fifo_stall, 0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2649
			if (!adapter->ecdev) netif_wake_queue(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2650
		} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2651
			if (!adapter->ecdev)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2652
				mod_timer(&adapter->tx_fifo_stall_timer, jiffies + 1);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2653
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2654
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2655
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2656
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2657
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2658
 * e1000_watchdog - Timer Call-back
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2659
 * @data: pointer to adapter cast into an unsigned long
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2660
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2661
static void e1000_watchdog(unsigned long data)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2662
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2663
	struct e1000_adapter *adapter = (struct e1000_adapter *)data;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2664
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2665
	struct net_device *netdev = adapter->netdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2666
	struct e1000_tx_ring *txdr = adapter->tx_ring;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2667
	u32 link, tctl;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2668
	s32 ret_val;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2669
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2670
	ret_val = e1000_check_for_link(hw);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2671
	if ((ret_val == E1000_ERR_PHY) &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2672
	    (hw->phy_type == e1000_phy_igp_3) &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2673
	    (er32(CTRL) & E1000_PHY_CTRL_GBE_DISABLE)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2674
		/* See e1000_kumeran_lock_loss_workaround() */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2675
		DPRINTK(LINK, INFO,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2676
			"Gigabit has been disabled, downgrading speed\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2677
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2678
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2679
	if (hw->mac_type == e1000_82573) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2680
		e1000_enable_tx_pkt_filtering(hw);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2681
		if (adapter->mng_vlan_id != hw->mng_cookie.vlan_id)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2682
			e1000_update_mng_vlan(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2683
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2684
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2685
	if ((hw->media_type == e1000_media_type_internal_serdes) &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2686
	   !(er32(TXCW) & E1000_TXCW_ANE))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2687
		link = !hw->serdes_link_down;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2688
	else
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2689
		link = er32(STATUS) & E1000_STATUS_LU;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2690
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2691
	if (link) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2692
		if ((adapter->ecdev && !ecdev_get_link(adapter->ecdev))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2693
				|| (!adapter->ecdev && !netif_carrier_ok(netdev))) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2694
			u32 ctrl;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2695
			bool txb2b = true;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2696
			e1000_get_speed_and_duplex(hw,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2697
			                           &adapter->link_speed,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2698
			                           &adapter->link_duplex);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2699
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2700
			ctrl = er32(CTRL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2701
			DPRINTK(LINK, INFO, "NIC Link is Up %d Mbps %s, "
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2702
			        "Flow Control: %s\n",
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2703
			        adapter->link_speed,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2704
			        adapter->link_duplex == FULL_DUPLEX ?
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2705
			        "Full Duplex" : "Half Duplex",
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2706
			        ((ctrl & E1000_CTRL_TFCE) && (ctrl &
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2707
			        E1000_CTRL_RFCE)) ? "RX/TX" : ((ctrl &
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2708
			        E1000_CTRL_RFCE) ? "RX" : ((ctrl &
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2709
			        E1000_CTRL_TFCE) ? "TX" : "None" )));
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2710
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2711
			/* tweak tx_queue_len according to speed/duplex
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2712
			 * and adjust the timeout factor */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2713
			netdev->tx_queue_len = adapter->tx_queue_len;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2714
			adapter->tx_timeout_factor = 1;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2715
			switch (adapter->link_speed) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2716
			case SPEED_10:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2717
				txb2b = false;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2718
				netdev->tx_queue_len = 10;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2719
				adapter->tx_timeout_factor = 8;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2720
				break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2721
			case SPEED_100:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2722
				txb2b = false;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2723
				netdev->tx_queue_len = 100;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2724
				/* maybe add some timeout factor ? */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2725
				break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2726
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2727
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2728
			if ((hw->mac_type == e1000_82571 ||
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2729
			     hw->mac_type == e1000_82572) &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2730
			    !txb2b) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2731
				u32 tarc0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2732
				tarc0 = er32(TARC0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2733
				tarc0 &= ~(1 << 21);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2734
				ew32(TARC0, tarc0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2735
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2736
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2737
			/* disable TSO for pcie and 10/100 speeds, to avoid
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2738
			 * some hardware issues */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2739
			if (!adapter->tso_force &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2740
			    hw->bus_type == e1000_bus_type_pci_express){
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2741
				switch (adapter->link_speed) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2742
				case SPEED_10:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2743
				case SPEED_100:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2744
					DPRINTK(PROBE,INFO,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2745
				        "10/100 speed: disabling TSO\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2746
					netdev->features &= ~NETIF_F_TSO;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2747
					netdev->features &= ~NETIF_F_TSO6;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2748
					break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2749
				case SPEED_1000:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2750
					netdev->features |= NETIF_F_TSO;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2751
					netdev->features |= NETIF_F_TSO6;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2752
					break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2753
				default:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2754
					/* oops */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2755
					break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2756
				}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2757
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2758
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2759
			/* enable transmits in the hardware, need to do this
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2760
			 * after setting TARC0 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2761
			tctl = er32(TCTL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2762
			tctl |= E1000_TCTL_EN;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2763
			ew32(TCTL, tctl);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2764
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2765
			if (adapter->ecdev) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2766
				ecdev_set_link(adapter->ecdev, 1);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2767
			} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2768
				netif_carrier_on(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2769
				netif_wake_queue(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2770
				mod_timer(&adapter->phy_info_timer, round_jiffies(jiffies + 2 * HZ));
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2771
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2772
			adapter->smartspeed = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2773
		} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2774
			/* make sure the receive unit is started */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2775
			if (hw->rx_needs_kicking) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2776
				u32 rctl = er32(RCTL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2777
				ew32(RCTL, rctl | E1000_RCTL_EN);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2778
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2779
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2780
	} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2781
		if ((adapter->ecdev && ecdev_get_link(adapter->ecdev))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2782
				|| (!adapter->ecdev && netif_carrier_ok(netdev))) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2783
			adapter->link_speed = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2784
			adapter->link_duplex = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2785
			DPRINTK(LINK, INFO, "NIC Link is Down\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2786
			if (adapter->ecdev) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2787
				ecdev_set_link(adapter->ecdev, 0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2788
			} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2789
				netif_carrier_off(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2790
				netif_stop_queue(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2791
				mod_timer(&adapter->phy_info_timer, round_jiffies(jiffies + 2 * HZ));
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2792
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2793
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2794
			/* 80003ES2LAN workaround--
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2795
			 * For packet buffer work-around on link down event;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2796
			 * disable receives in the ISR and
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2797
			 * reset device here in the watchdog
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2798
			 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2799
			if (hw->mac_type == e1000_80003es2lan)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2800
				/* reset device */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2801
				schedule_work(&adapter->reset_task);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2802
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2803
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2804
		e1000_smartspeed(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2805
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2806
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2807
	e1000_update_stats(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2808
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2809
	hw->tx_packet_delta = adapter->stats.tpt - adapter->tpt_old;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2810
	adapter->tpt_old = adapter->stats.tpt;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2811
	hw->collision_delta = adapter->stats.colc - adapter->colc_old;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2812
	adapter->colc_old = adapter->stats.colc;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2813
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2814
	adapter->gorcl = adapter->stats.gorcl - adapter->gorcl_old;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2815
	adapter->gorcl_old = adapter->stats.gorcl;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2816
	adapter->gotcl = adapter->stats.gotcl - adapter->gotcl_old;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2817
	adapter->gotcl_old = adapter->stats.gotcl;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2818
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2819
	e1000_update_adaptive(hw);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2820
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2821
	if (!adapter->ecdev && !netif_carrier_ok(netdev)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2822
		if (E1000_DESC_UNUSED(txdr) + 1 < txdr->count) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2823
			/* We've lost link, so the controller stops DMA,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2824
			 * but we've got queued Tx work that's never going
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2825
			 * to get done, so reset controller to flush Tx.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2826
			 * (Do the reset outside of interrupt context). */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2827
			adapter->tx_timeout_count++;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2828
			schedule_work(&adapter->reset_task);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2829
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2830
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2831
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2832
	/* Cause software interrupt to ensure rx ring is cleaned */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2833
	ew32(ICS, E1000_ICS_RXDMT0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2834
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2835
	/* Force detection of hung controller every watchdog period */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2836
	if (!adapter->ecdev) adapter->detect_tx_hung = true;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2837
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2838
	/* With 82571 controllers, LAA may be overwritten due to controller
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2839
	 * reset from the other port. Set the appropriate LAA in RAR[0] */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2840
	if (hw->mac_type == e1000_82571 && hw->laa_is_present)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2841
		e1000_rar_set(hw, hw->mac_addr, 0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2842
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2843
	/* Reset the timer */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2844
	if (!adapter->ecdev)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2845
		mod_timer(&adapter->watchdog_timer, round_jiffies(jiffies + 2 * HZ));
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2846
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2847
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2848
enum latency_range {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2849
	lowest_latency = 0,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2850
	low_latency = 1,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2851
	bulk_latency = 2,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2852
	latency_invalid = 255
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2853
};
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2854
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2855
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2856
 * e1000_update_itr - update the dynamic ITR value based on statistics
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2857
 *      Stores a new ITR value based on packets and byte
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2858
 *      counts during the last interrupt.  The advantage of per interrupt
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2859
 *      computation is faster updates and more accurate ITR for the current
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2860
 *      traffic pattern.  Constants in this function were computed
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2861
 *      based on theoretical maximum wire speed and thresholds were set based
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2862
 *      on testing data as well as attempting to minimize response time
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2863
 *      while increasing bulk throughput.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2864
 *      this functionality is controlled by the InterruptThrottleRate module
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2865
 *      parameter (see e1000_param.c)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2866
 * @adapter: pointer to adapter
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2867
 * @itr_setting: current adapter->itr
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2868
 * @packets: the number of packets during this measurement interval
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2869
 * @bytes: the number of bytes during this measurement interval
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2870
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2871
static unsigned int e1000_update_itr(struct e1000_adapter *adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2872
				     u16 itr_setting, int packets, int bytes)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2873
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2874
	unsigned int retval = itr_setting;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2875
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2876
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2877
	if (unlikely(hw->mac_type < e1000_82540))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2878
		goto update_itr_done;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2879
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2880
	if (packets == 0)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2881
		goto update_itr_done;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2882
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2883
	switch (itr_setting) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2884
	case lowest_latency:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2885
		/* jumbo frames get bulk treatment*/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2886
		if (bytes/packets > 8000)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2887
			retval = bulk_latency;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2888
		else if ((packets < 5) && (bytes > 512))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2889
			retval = low_latency;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2890
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2891
	case low_latency:  /* 50 usec aka 20000 ints/s */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2892
		if (bytes > 10000) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2893
			/* jumbo frames need bulk latency setting */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2894
			if (bytes/packets > 8000)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2895
				retval = bulk_latency;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2896
			else if ((packets < 10) || ((bytes/packets) > 1200))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2897
				retval = bulk_latency;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2898
			else if ((packets > 35))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2899
				retval = lowest_latency;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2900
		} else if (bytes/packets > 2000)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2901
			retval = bulk_latency;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2902
		else if (packets <= 2 && bytes < 512)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2903
			retval = lowest_latency;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2904
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2905
	case bulk_latency: /* 250 usec aka 4000 ints/s */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2906
		if (bytes > 25000) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2907
			if (packets > 35)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2908
				retval = low_latency;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2909
		} else if (bytes < 6000) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2910
			retval = low_latency;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2911
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2912
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2913
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2914
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2915
update_itr_done:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2916
	return retval;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2917
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2918
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2919
static void e1000_set_itr(struct e1000_adapter *adapter)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2920
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2921
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2922
	u16 current_itr;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2923
	u32 new_itr = adapter->itr;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2924
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2925
	if (unlikely(hw->mac_type < e1000_82540))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2926
		return;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2927
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2928
	/* for non-gigabit speeds, just fix the interrupt rate at 4000 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2929
	if (unlikely(adapter->link_speed != SPEED_1000)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2930
		current_itr = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2931
		new_itr = 4000;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2932
		goto set_itr_now;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2933
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2934
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2935
	adapter->tx_itr = e1000_update_itr(adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2936
	                            adapter->tx_itr,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2937
	                            adapter->total_tx_packets,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2938
	                            adapter->total_tx_bytes);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2939
	/* conservative mode (itr 3) eliminates the lowest_latency setting */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2940
	if (adapter->itr_setting == 3 && adapter->tx_itr == lowest_latency)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2941
		adapter->tx_itr = low_latency;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2942
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2943
	adapter->rx_itr = e1000_update_itr(adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2944
	                            adapter->rx_itr,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2945
	                            adapter->total_rx_packets,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2946
	                            adapter->total_rx_bytes);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2947
	/* conservative mode (itr 3) eliminates the lowest_latency setting */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2948
	if (adapter->itr_setting == 3 && adapter->rx_itr == lowest_latency)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2949
		adapter->rx_itr = low_latency;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2950
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2951
	current_itr = max(adapter->rx_itr, adapter->tx_itr);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2952
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2953
	switch (current_itr) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2954
	/* counts and packets in update_itr are dependent on these numbers */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2955
	case lowest_latency:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2956
		new_itr = 70000;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2957
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2958
	case low_latency:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2959
		new_itr = 20000; /* aka hwitr = ~200 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2960
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2961
	case bulk_latency:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2962
		new_itr = 4000;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2963
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2964
	default:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2965
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2966
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2967
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2968
set_itr_now:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2969
	if (new_itr != adapter->itr) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2970
		/* this attempts to bias the interrupt rate towards Bulk
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2971
		 * by adding intermediate steps when interrupt rate is
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2972
		 * increasing */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2973
		new_itr = new_itr > adapter->itr ?
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2974
		             min(adapter->itr + (new_itr >> 2), new_itr) :
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2975
		             new_itr;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2976
		adapter->itr = new_itr;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2977
		ew32(ITR, 1000000000 / (new_itr * 256));
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2978
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2979
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2980
	return;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2981
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2982
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2983
#define E1000_TX_FLAGS_CSUM		0x00000001
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2984
#define E1000_TX_FLAGS_VLAN		0x00000002
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2985
#define E1000_TX_FLAGS_TSO		0x00000004
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2986
#define E1000_TX_FLAGS_IPV4		0x00000008
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2987
#define E1000_TX_FLAGS_VLAN_MASK	0xffff0000
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2988
#define E1000_TX_FLAGS_VLAN_SHIFT	16
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2989
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2990
static int e1000_tso(struct e1000_adapter *adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2991
		     struct e1000_tx_ring *tx_ring, struct sk_buff *skb)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2992
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2993
	struct e1000_context_desc *context_desc;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2994
	struct e1000_buffer *buffer_info;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2995
	unsigned int i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2996
	u32 cmd_length = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2997
	u16 ipcse = 0, tucse, mss;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2998
	u8 ipcss, ipcso, tucss, tucso, hdr_len;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2999
	int err;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3000
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3001
	if (skb_is_gso(skb)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3002
		if (skb_header_cloned(skb)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3003
			err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3004
			if (err)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3005
				return err;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3006
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3007
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3008
		hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3009
		mss = skb_shinfo(skb)->gso_size;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3010
		if (skb->protocol == htons(ETH_P_IP)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3011
			struct iphdr *iph = ip_hdr(skb);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3012
			iph->tot_len = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3013
			iph->check = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3014
			tcp_hdr(skb)->check = ~csum_tcpudp_magic(iph->saddr,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3015
								 iph->daddr, 0,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3016
								 IPPROTO_TCP,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3017
								 0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3018
			cmd_length = E1000_TXD_CMD_IP;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3019
			ipcse = skb_transport_offset(skb) - 1;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3020
		} else if (skb->protocol == htons(ETH_P_IPV6)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3021
			ipv6_hdr(skb)->payload_len = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3022
			tcp_hdr(skb)->check =
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3023
				~csum_ipv6_magic(&ipv6_hdr(skb)->saddr,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3024
						 &ipv6_hdr(skb)->daddr,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3025
						 0, IPPROTO_TCP, 0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3026
			ipcse = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3027
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3028
		ipcss = skb_network_offset(skb);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3029
		ipcso = (void *)&(ip_hdr(skb)->check) - (void *)skb->data;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3030
		tucss = skb_transport_offset(skb);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3031
		tucso = (void *)&(tcp_hdr(skb)->check) - (void *)skb->data;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3032
		tucse = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3033
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3034
		cmd_length |= (E1000_TXD_CMD_DEXT | E1000_TXD_CMD_TSE |
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3035
			       E1000_TXD_CMD_TCP | (skb->len - (hdr_len)));
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3036
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3037
		i = tx_ring->next_to_use;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3038
		context_desc = E1000_CONTEXT_DESC(*tx_ring, i);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3039
		buffer_info = &tx_ring->buffer_info[i];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3040
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3041
		context_desc->lower_setup.ip_fields.ipcss  = ipcss;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3042
		context_desc->lower_setup.ip_fields.ipcso  = ipcso;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3043
		context_desc->lower_setup.ip_fields.ipcse  = cpu_to_le16(ipcse);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3044
		context_desc->upper_setup.tcp_fields.tucss = tucss;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3045
		context_desc->upper_setup.tcp_fields.tucso = tucso;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3046
		context_desc->upper_setup.tcp_fields.tucse = cpu_to_le16(tucse);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3047
		context_desc->tcp_seg_setup.fields.mss     = cpu_to_le16(mss);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3048
		context_desc->tcp_seg_setup.fields.hdr_len = hdr_len;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3049
		context_desc->cmd_and_length = cpu_to_le32(cmd_length);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3050
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3051
		buffer_info->time_stamp = jiffies;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3052
		buffer_info->next_to_watch = i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3053
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3054
		if (++i == tx_ring->count) i = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3055
		tx_ring->next_to_use = i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3056
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3057
		return true;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3058
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3059
	return false;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3060
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3061
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3062
static bool e1000_tx_csum(struct e1000_adapter *adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3063
			  struct e1000_tx_ring *tx_ring, struct sk_buff *skb)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3064
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3065
	struct e1000_context_desc *context_desc;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3066
	struct e1000_buffer *buffer_info;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3067
	unsigned int i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3068
	u8 css;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3069
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3070
	if (likely(skb->ip_summed == CHECKSUM_PARTIAL)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3071
		css = skb_transport_offset(skb);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3072
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3073
		i = tx_ring->next_to_use;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3074
		buffer_info = &tx_ring->buffer_info[i];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3075
		context_desc = E1000_CONTEXT_DESC(*tx_ring, i);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3076
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3077
		context_desc->lower_setup.ip_config = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3078
		context_desc->upper_setup.tcp_fields.tucss = css;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3079
		context_desc->upper_setup.tcp_fields.tucso =
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3080
			css + skb->csum_offset;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3081
		context_desc->upper_setup.tcp_fields.tucse = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3082
		context_desc->tcp_seg_setup.data = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3083
		context_desc->cmd_and_length = cpu_to_le32(E1000_TXD_CMD_DEXT);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3084
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3085
		buffer_info->time_stamp = jiffies;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3086
		buffer_info->next_to_watch = i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3087
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3088
		if (unlikely(++i == tx_ring->count)) i = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3089
		tx_ring->next_to_use = i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3090
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3091
		return true;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3092
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3093
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3094
	return false;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3095
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3096
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3097
#define E1000_MAX_TXD_PWR	12
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3098
#define E1000_MAX_DATA_PER_TXD	(1<<E1000_MAX_TXD_PWR)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3099
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3100
static int e1000_tx_map(struct e1000_adapter *adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3101
			struct e1000_tx_ring *tx_ring,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3102
			struct sk_buff *skb, unsigned int first,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3103
			unsigned int max_per_txd, unsigned int nr_frags,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3104
			unsigned int mss)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3105
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3106
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3107
	struct e1000_buffer *buffer_info;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3108
	unsigned int len = skb->len;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3109
	unsigned int offset = 0, size, count = 0, i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3110
	unsigned int f;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3111
	len -= skb->data_len;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3112
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3113
	i = tx_ring->next_to_use;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3114
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3115
	while (len) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3116
		buffer_info = &tx_ring->buffer_info[i];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3117
		size = min(len, max_per_txd);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3118
		/* Workaround for Controller erratum --
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3119
		 * descriptor for non-tso packet in a linear SKB that follows a
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3120
		 * tso gets written back prematurely before the data is fully
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3121
		 * DMA'd to the controller */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3122
		if (!skb->data_len && tx_ring->last_tx_tso &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3123
		    !skb_is_gso(skb)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3124
			tx_ring->last_tx_tso = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3125
			size -= 4;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3126
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3127
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3128
		/* Workaround for premature desc write-backs
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3129
		 * in TSO mode.  Append 4-byte sentinel desc */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3130
		if (unlikely(mss && !nr_frags && size == len && size > 8))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3131
			size -= 4;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3132
		/* work-around for errata 10 and it applies
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3133
		 * to all controllers in PCI-X mode
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3134
		 * The fix is to make sure that the first descriptor of a
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3135
		 * packet is smaller than 2048 - 16 - 16 (or 2016) bytes
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3136
		 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3137
		if (unlikely((hw->bus_type == e1000_bus_type_pcix) &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3138
		                (size > 2015) && count == 0))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3139
		        size = 2015;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3140
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3141
		/* Workaround for potential 82544 hang in PCI-X.  Avoid
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3142
		 * terminating buffers within evenly-aligned dwords. */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3143
		if (unlikely(adapter->pcix_82544 &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3144
		   !((unsigned long)(skb->data + offset + size - 1) & 4) &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3145
		   size > 4))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3146
			size -= 4;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3147
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3148
		buffer_info->length = size;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3149
		buffer_info->dma =
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3150
			pci_map_single(adapter->pdev,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3151
				skb->data + offset,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3152
				size,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3153
				PCI_DMA_TODEVICE);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3154
		buffer_info->time_stamp = jiffies;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3155
		buffer_info->next_to_watch = i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3156
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3157
		len -= size;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3158
		offset += size;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3159
		count++;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3160
		if (unlikely(++i == tx_ring->count)) i = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3161
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3162
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3163
	for (f = 0; f < nr_frags; f++) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3164
		struct skb_frag_struct *frag;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3165
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3166
		frag = &skb_shinfo(skb)->frags[f];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3167
		len = frag->size;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3168
		offset = frag->page_offset;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3169
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3170
		while (len) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3171
			buffer_info = &tx_ring->buffer_info[i];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3172
			size = min(len, max_per_txd);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3173
			/* Workaround for premature desc write-backs
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3174
			 * in TSO mode.  Append 4-byte sentinel desc */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3175
			if (unlikely(mss && f == (nr_frags-1) && size == len && size > 8))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3176
				size -= 4;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3177
			/* Workaround for potential 82544 hang in PCI-X.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3178
			 * Avoid terminating buffers within evenly-aligned
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3179
			 * dwords. */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3180
			if (unlikely(adapter->pcix_82544 &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3181
			   !((unsigned long)(frag->page+offset+size-1) & 4) &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3182
			   size > 4))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3183
				size -= 4;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3184
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3185
			buffer_info->length = size;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3186
			buffer_info->dma =
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3187
				pci_map_page(adapter->pdev,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3188
					frag->page,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3189
					offset,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3190
					size,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3191
					PCI_DMA_TODEVICE);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3192
			buffer_info->time_stamp = jiffies;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3193
			buffer_info->next_to_watch = i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3194
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3195
			len -= size;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3196
			offset += size;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3197
			count++;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3198
			if (unlikely(++i == tx_ring->count)) i = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3199
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3200
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3201
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3202
	i = (i == 0) ? tx_ring->count - 1 : i - 1;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3203
	tx_ring->buffer_info[i].skb = skb;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3204
	tx_ring->buffer_info[first].next_to_watch = i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3205
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3206
	return count;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3207
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3208
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3209
static void e1000_tx_queue(struct e1000_adapter *adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3210
			   struct e1000_tx_ring *tx_ring, int tx_flags,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3211
			   int count)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3212
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3213
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3214
	struct e1000_tx_desc *tx_desc = NULL;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3215
	struct e1000_buffer *buffer_info;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3216
	u32 txd_upper = 0, txd_lower = E1000_TXD_CMD_IFCS;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3217
	unsigned int i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3218
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3219
	if (likely(tx_flags & E1000_TX_FLAGS_TSO)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3220
		txd_lower |= E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D |
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3221
		             E1000_TXD_CMD_TSE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3222
		txd_upper |= E1000_TXD_POPTS_TXSM << 8;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3223
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3224
		if (likely(tx_flags & E1000_TX_FLAGS_IPV4))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3225
			txd_upper |= E1000_TXD_POPTS_IXSM << 8;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3226
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3227
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3228
	if (likely(tx_flags & E1000_TX_FLAGS_CSUM)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3229
		txd_lower |= E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3230
		txd_upper |= E1000_TXD_POPTS_TXSM << 8;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3231
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3232
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3233
	if (unlikely(tx_flags & E1000_TX_FLAGS_VLAN)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3234
		txd_lower |= E1000_TXD_CMD_VLE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3235
		txd_upper |= (tx_flags & E1000_TX_FLAGS_VLAN_MASK);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3236
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3237
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3238
	i = tx_ring->next_to_use;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3239
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3240
	while (count--) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3241
		buffer_info = &tx_ring->buffer_info[i];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3242
		tx_desc = E1000_TX_DESC(*tx_ring, i);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3243
		tx_desc->buffer_addr = cpu_to_le64(buffer_info->dma);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3244
		tx_desc->lower.data =
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3245
			cpu_to_le32(txd_lower | buffer_info->length);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3246
		tx_desc->upper.data = cpu_to_le32(txd_upper);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3247
		if (unlikely(++i == tx_ring->count)) i = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3248
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3249
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3250
	tx_desc->lower.data |= cpu_to_le32(adapter->txd_cmd);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3251
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3252
	/* Force memory writes to complete before letting h/w
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3253
	 * know there are new descriptors to fetch.  (Only
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3254
	 * applicable for weak-ordered memory model archs,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3255
	 * such as IA-64). */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3256
	wmb();
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3257
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3258
	tx_ring->next_to_use = i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3259
	writel(i, hw->hw_addr + tx_ring->tdt);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3260
	/* we need this if more than one processor can write to our tail
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3261
	 * at a time, it syncronizes IO on IA64/Altix systems */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3262
	mmiowb();
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3263
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3264
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3265
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3266
 * 82547 workaround to avoid controller hang in half-duplex environment.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3267
 * The workaround is to avoid queuing a large packet that would span
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3268
 * the internal Tx FIFO ring boundary by notifying the stack to resend
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3269
 * the packet at a later time.  This gives the Tx FIFO an opportunity to
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3270
 * flush all packets.  When that occurs, we reset the Tx FIFO pointers
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3271
 * to the beginning of the Tx FIFO.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3272
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3273
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3274
#define E1000_FIFO_HDR			0x10
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3275
#define E1000_82547_PAD_LEN		0x3E0
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3276
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3277
static int e1000_82547_fifo_workaround(struct e1000_adapter *adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3278
				       struct sk_buff *skb)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3279
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3280
	u32 fifo_space = adapter->tx_fifo_size - adapter->tx_fifo_head;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3281
	u32 skb_fifo_len = skb->len + E1000_FIFO_HDR;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3282
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3283
	skb_fifo_len = ALIGN(skb_fifo_len, E1000_FIFO_HDR);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3284
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3285
	if (adapter->link_duplex != HALF_DUPLEX)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3286
		goto no_fifo_stall_required;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3287
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3288
	if (atomic_read(&adapter->tx_fifo_stall))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3289
		return 1;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3290
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3291
	if (skb_fifo_len >= (E1000_82547_PAD_LEN + fifo_space)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3292
		atomic_set(&adapter->tx_fifo_stall, 1);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3293
		return 1;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3294
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3295
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3296
no_fifo_stall_required:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3297
	adapter->tx_fifo_head += skb_fifo_len;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3298
	if (adapter->tx_fifo_head >= adapter->tx_fifo_size)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3299
		adapter->tx_fifo_head -= adapter->tx_fifo_size;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3300
	return 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3301
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3302
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3303
#define MINIMUM_DHCP_PACKET_SIZE 282
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3304
static int e1000_transfer_dhcp_info(struct e1000_adapter *adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3305
				    struct sk_buff *skb)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3306
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3307
	struct e1000_hw *hw =  &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3308
	u16 length, offset;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3309
	if (vlan_tx_tag_present(skb)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3310
		if (!((vlan_tx_tag_get(skb) == hw->mng_cookie.vlan_id) &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3311
			( hw->mng_cookie.status &
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3312
			  E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) )
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3313
			return 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3314
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3315
	if (skb->len > MINIMUM_DHCP_PACKET_SIZE) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3316
		struct ethhdr *eth = (struct ethhdr *)skb->data;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3317
		if ((htons(ETH_P_IP) == eth->h_proto)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3318
			const struct iphdr *ip =
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3319
				(struct iphdr *)((u8 *)skb->data+14);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3320
			if (IPPROTO_UDP == ip->protocol) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3321
				struct udphdr *udp =
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3322
					(struct udphdr *)((u8 *)ip +
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3323
						(ip->ihl << 2));
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3324
				if (ntohs(udp->dest) == 67) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3325
					offset = (u8 *)udp + 8 - skb->data;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3326
					length = skb->len - offset;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3327
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3328
					return e1000_mng_write_dhcp_info(hw,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3329
							(u8 *)udp + 8,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3330
							length);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3331
				}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3332
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3333
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3334
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3335
	return 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3336
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3337
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3338
static int __e1000_maybe_stop_tx(struct net_device *netdev, int size)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3339
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3340
	struct e1000_adapter *adapter = netdev_priv(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3341
	struct e1000_tx_ring *tx_ring = adapter->tx_ring;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3342
2471
fc64a4b1ec1a Fixed __e1000_maybe_stop_tx().
Florian Pose <fp@igh-essen.com>
parents: 2469
diff changeset
  3343
	if (adapter->ecdev) {
fc64a4b1ec1a Fixed __e1000_maybe_stop_tx().
Florian Pose <fp@igh-essen.com>
parents: 2469
diff changeset
  3344
		return -EBUSY;
fc64a4b1ec1a Fixed __e1000_maybe_stop_tx().
Florian Pose <fp@igh-essen.com>
parents: 2469
diff changeset
  3345
	}
fc64a4b1ec1a Fixed __e1000_maybe_stop_tx().
Florian Pose <fp@igh-essen.com>
parents: 2469
diff changeset
  3346
1900
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3347
	netif_stop_queue(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3348
	/* Herbert's original patch had:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3349
	 *  smp_mb__after_netif_stop_queue();
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3350
	 * but since that doesn't exist yet, just open code it. */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3351
	smp_mb();
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3352
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3353
	/* We need to check again in a case another CPU has just
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3354
	 * made room available. */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3355
	if (likely(E1000_DESC_UNUSED(tx_ring) < size))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3356
		return -EBUSY;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3357
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3358
	/* A reprieve! */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3359
	netif_start_queue(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3360
	++adapter->restart_queue;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3361
	return 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3362
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3363
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3364
static int e1000_maybe_stop_tx(struct net_device *netdev,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3365
                               struct e1000_tx_ring *tx_ring, int size)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3366
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3367
	if (likely(E1000_DESC_UNUSED(tx_ring) >= size))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3368
		return 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3369
	return __e1000_maybe_stop_tx(netdev, size);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3370
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3371
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3372
#define TXD_USE_COUNT(S, X) (((S) >> (X)) + 1 )
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3373
static int e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3374
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3375
	struct e1000_adapter *adapter = netdev_priv(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3376
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3377
	struct e1000_tx_ring *tx_ring;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3378
	unsigned int first, max_per_txd = E1000_MAX_DATA_PER_TXD;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3379
	unsigned int max_txd_pwr = E1000_MAX_TXD_PWR;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3380
	unsigned int tx_flags = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3381
	unsigned int len = skb->len - skb->data_len;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3382
	unsigned long flags = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3383
	unsigned int nr_frags = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3384
	unsigned int mss = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3385
	int count = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3386
	int tso;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3387
	unsigned int f;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3388
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3389
	/* This goes back to the question of how to logically map a tx queue
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3390
	 * to a flow.  Right now, performance is impacted slightly negatively
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3391
	 * if using multiple tx queues.  If the stack breaks away from a
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3392
	 * single qdisc implementation, we can look at this again. */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3393
	tx_ring = adapter->tx_ring;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3394
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3395
	if (unlikely(skb->len <= 0)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3396
		if (!adapter->ecdev)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3397
			dev_kfree_skb_any(skb);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3398
		return NETDEV_TX_OK;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3399
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3400
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3401
	/* 82571 and newer doesn't need the workaround that limited descriptor
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3402
	 * length to 4kB */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3403
	if (hw->mac_type >= e1000_82571)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3404
		max_per_txd = 8192;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3405
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3406
	mss = skb_shinfo(skb)->gso_size;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3407
	/* The controller does a simple calculation to
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3408
	 * make sure there is enough room in the FIFO before
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3409
	 * initiating the DMA for each buffer.  The calc is:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3410
	 * 4 = ceil(buffer len/mss).  To make sure we don't
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3411
	 * overrun the FIFO, adjust the max buffer len if mss
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3412
	 * drops. */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3413
	if (mss) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3414
		u8 hdr_len;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3415
		max_per_txd = min(mss << 2, max_per_txd);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3416
		max_txd_pwr = fls(max_per_txd) - 1;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3417
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3418
		/* TSO Workaround for 82571/2/3 Controllers -- if skb->data
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3419
		* points to just header, pull a few bytes of payload from
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3420
		* frags into skb->data */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3421
		hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3422
		if (skb->data_len && hdr_len == len) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3423
			switch (hw->mac_type) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3424
				unsigned int pull_size;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3425
			case e1000_82544:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3426
				/* Make sure we have room to chop off 4 bytes,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3427
				 * and that the end alignment will work out to
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3428
				 * this hardware's requirements
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3429
				 * NOTE: this is a TSO only workaround
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3430
				 * if end byte alignment not correct move us
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3431
				 * into the next dword */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3432
				if ((unsigned long)(skb_tail_pointer(skb) - 1) & 4)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3433
					break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3434
				/* fall through */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3435
			case e1000_82571:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3436
			case e1000_82572:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3437
			case e1000_82573:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3438
			case e1000_ich8lan:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3439
				pull_size = min((unsigned int)4, skb->data_len);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3440
				if (!__pskb_pull_tail(skb, pull_size)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3441
					DPRINTK(DRV, ERR,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3442
						"__pskb_pull_tail failed.\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3443
					dev_kfree_skb_any(skb);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3444
					return NETDEV_TX_OK;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3445
				}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3446
				len = skb->len - skb->data_len;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3447
				break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3448
			default:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3449
				/* do nothing */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3450
				break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3451
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3452
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3453
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3454
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3455
	/* reserve a descriptor for the offload context */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3456
	if ((mss) || (skb->ip_summed == CHECKSUM_PARTIAL))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3457
		count++;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3458
	count++;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3459
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3460
	/* Controller Erratum workaround */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3461
	if (!skb->data_len && tx_ring->last_tx_tso && !skb_is_gso(skb))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3462
		count++;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3463
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3464
	count += TXD_USE_COUNT(len, max_txd_pwr);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3465
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3466
	if (adapter->pcix_82544)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3467
		count++;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3468
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3469
	/* work-around for errata 10 and it applies to all controllers
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3470
	 * in PCI-X mode, so add one more descriptor to the count
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3471
	 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3472
	if (unlikely((hw->bus_type == e1000_bus_type_pcix) &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3473
			(len > 2015)))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3474
		count++;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3475
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3476
	nr_frags = skb_shinfo(skb)->nr_frags;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3477
	for (f = 0; f < nr_frags; f++)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3478
		count += TXD_USE_COUNT(skb_shinfo(skb)->frags[f].size,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3479
				       max_txd_pwr);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3480
	if (adapter->pcix_82544)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3481
		count += nr_frags;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3482
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3483
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3484
	if (hw->tx_pkt_filtering &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3485
	    (hw->mac_type == e1000_82573))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3486
		e1000_transfer_dhcp_info(adapter, skb);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3487
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3488
 	if (!adapter->ecdev &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3489
 			!spin_trylock_irqsave(&tx_ring->tx_lock, flags))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3490
		/* Collision - tell upper layer to requeue */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3491
		return NETDEV_TX_LOCKED;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3492
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3493
	/* need: count + 2 desc gap to keep tail from touching
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3494
	 * head, otherwise try next time */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3495
	if (unlikely(e1000_maybe_stop_tx(netdev, tx_ring, count + 2))) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3496
		if (!adapter->ecdev) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3497
			spin_unlock_irqrestore(&tx_ring->tx_lock, flags);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3498
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3499
		return NETDEV_TX_BUSY;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3500
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3501
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3502
	if (unlikely(hw->mac_type == e1000_82547)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3503
		if (unlikely(e1000_82547_fifo_workaround(adapter, skb))) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3504
			if (!adapter->ecdev) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3505
				netif_stop_queue(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3506
				mod_timer(&adapter->tx_fifo_stall_timer, jiffies + 1);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3507
				spin_unlock_irqrestore(&tx_ring->tx_lock, flags);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3508
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3509
			return NETDEV_TX_BUSY;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3510
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3511
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3512
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3513
	if (unlikely(adapter->vlgrp && vlan_tx_tag_present(skb))) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3514
		tx_flags |= E1000_TX_FLAGS_VLAN;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3515
		tx_flags |= (vlan_tx_tag_get(skb) << E1000_TX_FLAGS_VLAN_SHIFT);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3516
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3517
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3518
	first = tx_ring->next_to_use;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3519
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3520
	tso = e1000_tso(adapter, tx_ring, skb);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3521
	if (tso < 0) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3522
		if (!adapter->ecdev) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3523
			dev_kfree_skb_any(skb);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3524
			spin_unlock_irqrestore(&tx_ring->tx_lock, flags);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3525
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3526
		return NETDEV_TX_OK;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3527
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3528
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3529
	if (likely(tso)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3530
		tx_ring->last_tx_tso = 1;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3531
		tx_flags |= E1000_TX_FLAGS_TSO;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3532
	} else if (likely(e1000_tx_csum(adapter, tx_ring, skb)))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3533
		tx_flags |= E1000_TX_FLAGS_CSUM;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3534
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3535
	/* Old method was to assume IPv4 packet by default if TSO was enabled.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3536
	 * 82571 hardware supports TSO capabilities for IPv6 as well...
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3537
	 * no longer assume, we must. */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3538
	if (likely(skb->protocol == htons(ETH_P_IP)))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3539
		tx_flags |= E1000_TX_FLAGS_IPV4;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3540
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3541
	e1000_tx_queue(adapter, tx_ring, tx_flags,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3542
	               e1000_tx_map(adapter, tx_ring, skb, first,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3543
	                            max_per_txd, nr_frags, mss));
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3544
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3545
	netdev->trans_start = jiffies;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3546
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3547
	if (!adapter->ecdev) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3548
		/* Make sure there is space in the ring for the next send. */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3549
		e1000_maybe_stop_tx(netdev, tx_ring, MAX_SKB_FRAGS + 2);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3550
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3551
		spin_unlock_irqrestore(&tx_ring->tx_lock, flags);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3552
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3553
	return NETDEV_TX_OK;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3554
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3555
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3556
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3557
 * e1000_tx_timeout - Respond to a Tx Hang
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3558
 * @netdev: network interface device structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3559
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3560
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3561
static void e1000_tx_timeout(struct net_device *netdev)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3562
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3563
	struct e1000_adapter *adapter = netdev_priv(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3564
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3565
	/* Do the reset outside of interrupt context */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3566
	adapter->tx_timeout_count++;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3567
	schedule_work(&adapter->reset_task);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3568
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3569
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3570
static void e1000_reset_task(struct work_struct *work)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3571
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3572
	struct e1000_adapter *adapter =
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3573
		container_of(work, struct e1000_adapter, reset_task);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3574
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3575
	e1000_reinit_locked(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3576
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3577
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3578
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3579
 * e1000_get_stats - Get System Network Statistics
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3580
 * @netdev: network interface device structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3581
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3582
 * Returns the address of the device statistics structure.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3583
 * The statistics are actually updated from the timer callback.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3584
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3585
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3586
static struct net_device_stats *e1000_get_stats(struct net_device *netdev)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3587
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3588
	struct e1000_adapter *adapter = netdev_priv(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3589
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3590
	/* only return the current stats */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3591
	return &adapter->net_stats;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3592
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3593
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3594
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3595
 * e1000_change_mtu - Change the Maximum Transfer Unit
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3596
 * @netdev: network interface device structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3597
 * @new_mtu: new value for maximum frame size
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3598
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3599
 * Returns 0 on success, negative on failure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3600
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3601
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3602
static int e1000_change_mtu(struct net_device *netdev, int new_mtu)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3603
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3604
	struct e1000_adapter *adapter = netdev_priv(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3605
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3606
	int max_frame = new_mtu + ENET_HEADER_SIZE + ETHERNET_FCS_SIZE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3607
	u16 eeprom_data = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3608
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3609
	if (adapter->ecdev)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3610
		return -EBUSY;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3611
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3612
	if ((max_frame < MINIMUM_ETHERNET_FRAME_SIZE) ||
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3613
	    (max_frame > MAX_JUMBO_FRAME_SIZE)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3614
		DPRINTK(PROBE, ERR, "Invalid MTU setting\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3615
		return -EINVAL;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3616
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3617
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3618
	/* Adapter-specific max frame size limits. */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3619
	switch (hw->mac_type) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3620
	case e1000_undefined ... e1000_82542_rev2_1:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3621
	case e1000_ich8lan:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3622
		if (max_frame > MAXIMUM_ETHERNET_FRAME_SIZE) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3623
			DPRINTK(PROBE, ERR, "Jumbo Frames not supported.\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3624
			return -EINVAL;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3625
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3626
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3627
	case e1000_82573:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3628
		/* Jumbo Frames not supported if:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3629
		 * - this is not an 82573L device
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3630
		 * - ASPM is enabled in any way (0x1A bits 3:2) */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3631
		e1000_read_eeprom(hw, EEPROM_INIT_3GIO_3, 1,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3632
		                  &eeprom_data);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3633
		if ((hw->device_id != E1000_DEV_ID_82573L) ||
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3634
		    (eeprom_data & EEPROM_WORD1A_ASPM_MASK)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3635
			if (max_frame > MAXIMUM_ETHERNET_FRAME_SIZE) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3636
				DPRINTK(PROBE, ERR,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3637
			            	"Jumbo Frames not supported.\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3638
				return -EINVAL;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3639
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3640
			break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3641
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3642
		/* ERT will be enabled later to enable wire speed receives */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3643
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3644
		/* fall through to get support */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3645
	case e1000_82571:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3646
	case e1000_82572:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3647
	case e1000_80003es2lan:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3648
#define MAX_STD_JUMBO_FRAME_SIZE 9234
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3649
		if (max_frame > MAX_STD_JUMBO_FRAME_SIZE) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3650
			DPRINTK(PROBE, ERR, "MTU > 9216 not supported.\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3651
			return -EINVAL;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3652
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3653
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3654
	default:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3655
		/* Capable of supporting up to MAX_JUMBO_FRAME_SIZE limit. */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3656
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3657
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3658
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3659
	/* NOTE: netdev_alloc_skb reserves 16 bytes, and typically NET_IP_ALIGN
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3660
	 * means we reserve 2 more, this pushes us to allocate from the next
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3661
	 * larger slab size
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3662
	 * i.e. RXBUFFER_2048 --> size-4096 slab */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3663
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3664
	if (max_frame <= E1000_RXBUFFER_256)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3665
		adapter->rx_buffer_len = E1000_RXBUFFER_256;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3666
	else if (max_frame <= E1000_RXBUFFER_512)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3667
		adapter->rx_buffer_len = E1000_RXBUFFER_512;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3668
	else if (max_frame <= E1000_RXBUFFER_1024)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3669
		adapter->rx_buffer_len = E1000_RXBUFFER_1024;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3670
	else if (max_frame <= E1000_RXBUFFER_2048)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3671
		adapter->rx_buffer_len = E1000_RXBUFFER_2048;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3672
	else if (max_frame <= E1000_RXBUFFER_4096)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3673
		adapter->rx_buffer_len = E1000_RXBUFFER_4096;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3674
	else if (max_frame <= E1000_RXBUFFER_8192)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3675
		adapter->rx_buffer_len = E1000_RXBUFFER_8192;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3676
	else if (max_frame <= E1000_RXBUFFER_16384)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3677
		adapter->rx_buffer_len = E1000_RXBUFFER_16384;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3678
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3679
	/* adjust allocation if LPE protects us, and we aren't using SBP */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3680
	if (!hw->tbi_compatibility_on &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3681
	    ((max_frame == MAXIMUM_ETHERNET_FRAME_SIZE) ||
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3682
	     (max_frame == MAXIMUM_ETHERNET_VLAN_SIZE)))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3683
		adapter->rx_buffer_len = MAXIMUM_ETHERNET_VLAN_SIZE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3684
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3685
	netdev->mtu = new_mtu;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3686
	hw->max_frame_size = max_frame;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3687
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3688
	if (netif_running(netdev))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3689
		e1000_reinit_locked(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3690
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3691
	return 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3692
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3693
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3694
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3695
 * e1000_update_stats - Update the board statistics counters
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3696
 * @adapter: board private structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3697
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3698
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3699
void e1000_update_stats(struct e1000_adapter *adapter)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3700
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3701
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3702
	struct pci_dev *pdev = adapter->pdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3703
	unsigned long flags = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3704
	u16 phy_tmp;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3705
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3706
#define PHY_IDLE_ERROR_COUNT_MASK 0x00FF
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3707
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3708
	/*
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3709
	 * Prevent stats update while adapter is being reset, or if the pci
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3710
	 * connection is down.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3711
	 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3712
	if (adapter->link_speed == 0)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3713
		return;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3714
	if (pci_channel_offline(pdev))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3715
		return;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3716
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3717
	if (!adapter->ecdev)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3718
		spin_lock_irqsave(&adapter->stats_lock, flags);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3719
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3720
	/* these counters are modified from e1000_tbi_adjust_stats,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3721
	 * called from the interrupt context, so they must only
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3722
	 * be written while holding adapter->stats_lock
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3723
	 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3724
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3725
	adapter->stats.crcerrs += er32(CRCERRS);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3726
	adapter->stats.gprc += er32(GPRC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3727
	adapter->stats.gorcl += er32(GORCL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3728
	adapter->stats.gorch += er32(GORCH);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3729
	adapter->stats.bprc += er32(BPRC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3730
	adapter->stats.mprc += er32(MPRC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3731
	adapter->stats.roc += er32(ROC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3732
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3733
	if (hw->mac_type != e1000_ich8lan) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3734
		adapter->stats.prc64 += er32(PRC64);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3735
		adapter->stats.prc127 += er32(PRC127);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3736
		adapter->stats.prc255 += er32(PRC255);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3737
		adapter->stats.prc511 += er32(PRC511);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3738
		adapter->stats.prc1023 += er32(PRC1023);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3739
		adapter->stats.prc1522 += er32(PRC1522);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3740
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3741
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3742
	adapter->stats.symerrs += er32(SYMERRS);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3743
	adapter->stats.mpc += er32(MPC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3744
	adapter->stats.scc += er32(SCC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3745
	adapter->stats.ecol += er32(ECOL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3746
	adapter->stats.mcc += er32(MCC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3747
	adapter->stats.latecol += er32(LATECOL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3748
	adapter->stats.dc += er32(DC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3749
	adapter->stats.sec += er32(SEC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3750
	adapter->stats.rlec += er32(RLEC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3751
	adapter->stats.xonrxc += er32(XONRXC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3752
	adapter->stats.xontxc += er32(XONTXC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3753
	adapter->stats.xoffrxc += er32(XOFFRXC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3754
	adapter->stats.xofftxc += er32(XOFFTXC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3755
	adapter->stats.fcruc += er32(FCRUC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3756
	adapter->stats.gptc += er32(GPTC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3757
	adapter->stats.gotcl += er32(GOTCL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3758
	adapter->stats.gotch += er32(GOTCH);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3759
	adapter->stats.rnbc += er32(RNBC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3760
	adapter->stats.ruc += er32(RUC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3761
	adapter->stats.rfc += er32(RFC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3762
	adapter->stats.rjc += er32(RJC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3763
	adapter->stats.torl += er32(TORL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3764
	adapter->stats.torh += er32(TORH);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3765
	adapter->stats.totl += er32(TOTL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3766
	adapter->stats.toth += er32(TOTH);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3767
	adapter->stats.tpr += er32(TPR);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3768
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3769
	if (hw->mac_type != e1000_ich8lan) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3770
		adapter->stats.ptc64 += er32(PTC64);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3771
		adapter->stats.ptc127 += er32(PTC127);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3772
		adapter->stats.ptc255 += er32(PTC255);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3773
		adapter->stats.ptc511 += er32(PTC511);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3774
		adapter->stats.ptc1023 += er32(PTC1023);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3775
		adapter->stats.ptc1522 += er32(PTC1522);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3776
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3777
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3778
	adapter->stats.mptc += er32(MPTC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3779
	adapter->stats.bptc += er32(BPTC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3780
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3781
	/* used for adaptive IFS */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3782
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3783
	hw->tx_packet_delta = er32(TPT);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3784
	adapter->stats.tpt += hw->tx_packet_delta;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3785
	hw->collision_delta = er32(COLC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3786
	adapter->stats.colc += hw->collision_delta;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3787
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3788
	if (hw->mac_type >= e1000_82543) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3789
		adapter->stats.algnerrc += er32(ALGNERRC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3790
		adapter->stats.rxerrc += er32(RXERRC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3791
		adapter->stats.tncrs += er32(TNCRS);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3792
		adapter->stats.cexterr += er32(CEXTERR);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3793
		adapter->stats.tsctc += er32(TSCTC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3794
		adapter->stats.tsctfc += er32(TSCTFC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3795
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3796
	if (hw->mac_type > e1000_82547_rev_2) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3797
		adapter->stats.iac += er32(IAC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3798
		adapter->stats.icrxoc += er32(ICRXOC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3799
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3800
		if (hw->mac_type != e1000_ich8lan) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3801
			adapter->stats.icrxptc += er32(ICRXPTC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3802
			adapter->stats.icrxatc += er32(ICRXATC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3803
			adapter->stats.ictxptc += er32(ICTXPTC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3804
			adapter->stats.ictxatc += er32(ICTXATC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3805
			adapter->stats.ictxqec += er32(ICTXQEC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3806
			adapter->stats.ictxqmtc += er32(ICTXQMTC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3807
			adapter->stats.icrxdmtc += er32(ICRXDMTC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3808
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3809
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3810
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3811
	/* Fill out the OS statistics structure */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3812
	adapter->net_stats.multicast = adapter->stats.mprc;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3813
	adapter->net_stats.collisions = adapter->stats.colc;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3814
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3815
	/* Rx Errors */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3816
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3817
	/* RLEC on some newer hardware can be incorrect so build
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3818
	* our own version based on RUC and ROC */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3819
	adapter->net_stats.rx_errors = adapter->stats.rxerrc +
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3820
		adapter->stats.crcerrs + adapter->stats.algnerrc +
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3821
		adapter->stats.ruc + adapter->stats.roc +
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3822
		adapter->stats.cexterr;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3823
	adapter->stats.rlerrc = adapter->stats.ruc + adapter->stats.roc;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3824
	adapter->net_stats.rx_length_errors = adapter->stats.rlerrc;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3825
	adapter->net_stats.rx_crc_errors = adapter->stats.crcerrs;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3826
	adapter->net_stats.rx_frame_errors = adapter->stats.algnerrc;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3827
	adapter->net_stats.rx_missed_errors = adapter->stats.mpc;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3828
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3829
	/* Tx Errors */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3830
	adapter->stats.txerrc = adapter->stats.ecol + adapter->stats.latecol;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3831
	adapter->net_stats.tx_errors = adapter->stats.txerrc;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3832
	adapter->net_stats.tx_aborted_errors = adapter->stats.ecol;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3833
	adapter->net_stats.tx_window_errors = adapter->stats.latecol;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3834
	adapter->net_stats.tx_carrier_errors = adapter->stats.tncrs;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3835
	if (hw->bad_tx_carr_stats_fd &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3836
	    adapter->link_duplex == FULL_DUPLEX) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3837
		adapter->net_stats.tx_carrier_errors = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3838
		adapter->stats.tncrs = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3839
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3840
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3841
	/* Tx Dropped needs to be maintained elsewhere */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3842
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3843
	/* Phy Stats */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3844
	if (hw->media_type == e1000_media_type_copper) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3845
		if ((adapter->link_speed == SPEED_1000) &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3846
		   (!e1000_read_phy_reg(hw, PHY_1000T_STATUS, &phy_tmp))) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3847
			phy_tmp &= PHY_IDLE_ERROR_COUNT_MASK;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3848
			adapter->phy_stats.idle_errors += phy_tmp;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3849
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3850
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3851
		if ((hw->mac_type <= e1000_82546) &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3852
		   (hw->phy_type == e1000_phy_m88) &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3853
		   !e1000_read_phy_reg(hw, M88E1000_RX_ERR_CNTR, &phy_tmp))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3854
			adapter->phy_stats.receive_errors += phy_tmp;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3855
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3856
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3857
	/* Management Stats */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3858
	if (hw->has_smbus) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3859
		adapter->stats.mgptc += er32(MGTPTC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3860
		adapter->stats.mgprc += er32(MGTPRC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3861
		adapter->stats.mgpdc += er32(MGTPDC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3862
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3863
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3864
	if (!adapter->ecdev)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3865
		spin_unlock_irqrestore(&adapter->stats_lock, flags);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3866
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3867
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3868
void ec_poll(struct net_device *netdev)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3869
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3870
    struct e1000_adapter *adapter = netdev_priv(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3871
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3872
    if (jiffies - adapter->ec_watchdog_jiffies >= 2 * HZ) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3873
        e1000_watchdog((unsigned long) adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3874
        adapter->ec_watchdog_jiffies = jiffies;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3875
    }
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3876
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3877
#ifdef CONFIG_PCI_MSI
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3878
	e1000_intr_msi(0, netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3879
#else
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3880
    e1000_intr(0, netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3881
#endif
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3882
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3883
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3884
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3885
 * e1000_intr_msi - Interrupt Handler
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3886
 * @irq: interrupt number
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3887
 * @data: pointer to a network interface device structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3888
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3889
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3890
static irqreturn_t e1000_intr_msi(int irq, void *data)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3891
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3892
	struct net_device *netdev = data;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3893
	struct e1000_adapter *adapter = netdev_priv(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3894
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3895
	u32 icr = er32(ICR);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3896
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3897
 	if (adapter->ecdev) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3898
 		int i, ec_work_done = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3899
 		for (i = 0; i < E1000_MAX_INTR; i++) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3900
 			if (unlikely(!adapter->clean_rx(adapter, adapter->rx_ring,
2050
a3e59f2a8589 Changed accidentally used & operator to &&.
Florian Pose <fp@igh-essen.com>
parents: 1900
diff changeset
  3901
                             &ec_work_done, 100) &&
1900
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3902
 						!e1000_clean_tx_irq(adapter, adapter->tx_ring))) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3903
 				break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3904
 			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3905
 		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3906
 	} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3907
		/* in NAPI mode read ICR disables interrupts using IAM */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3908
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3909
		if (icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3910
			hw->get_link_status = 1;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3911
			/* 80003ES2LAN workaround-- For packet buffer work-around on
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3912
			 * link down event; disable receives here in the ISR and reset
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3913
			 * adapter in watchdog */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3914
			if (netif_carrier_ok(netdev) &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3915
				(hw->mac_type == e1000_80003es2lan)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3916
				/* disable receives */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3917
				u32 rctl = er32(RCTL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3918
				ew32(RCTL, rctl & ~E1000_RCTL_EN);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3919
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3920
			/* guard against interrupt when we're going down */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3921
			if (!test_bit(__E1000_DOWN, &adapter->flags))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3922
				mod_timer(&adapter->watchdog_timer, jiffies + 1);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3923
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3924
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3925
		if (likely(netif_rx_schedule_prep(netdev, &adapter->napi))) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3926
			adapter->total_tx_bytes = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3927
			adapter->total_tx_packets = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3928
			adapter->total_rx_bytes = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3929
			adapter->total_rx_packets = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3930
			__netif_rx_schedule(netdev, &adapter->napi);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3931
		} else
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3932
			e1000_irq_enable(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3933
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3934
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3935
	return IRQ_HANDLED;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3936
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3937
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3938
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3939
 * e1000_intr - Interrupt Handler
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3940
 * @irq: interrupt number
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3941
 * @data: pointer to a network interface device structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3942
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3943
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3944
static irqreturn_t e1000_intr(int irq, void *data)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3945
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3946
	struct net_device *netdev = data;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3947
	struct e1000_adapter *adapter = netdev_priv(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3948
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3949
	u32 rctl, icr = er32(ICR);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3950
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3951
	if (unlikely((!icr) || test_bit(__E1000_RESETTING, &adapter->flags)))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3952
		return IRQ_NONE;  /* Not our interrupt */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3953
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3954
	/* IMS will not auto-mask if INT_ASSERTED is not set, and if it is
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3955
	 * not set, then the adapter didn't send an interrupt */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3956
	if (unlikely(hw->mac_type >= e1000_82571 &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3957
	             !(icr & E1000_ICR_INT_ASSERTED)))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3958
		return IRQ_NONE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3959
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3960
	/* Interrupt Auto-Mask...upon reading ICR, interrupts are masked.  No
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3961
	 * need for the IMC write */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3962
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3963
	if (!adapter->ecdev && unlikely(icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC))) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3964
		hw->get_link_status = 1;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3965
		/* 80003ES2LAN workaround--
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3966
		 * For packet buffer work-around on link down event;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3967
		 * disable receives here in the ISR and
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3968
		 * reset adapter in watchdog
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3969
		 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3970
		if (netif_carrier_ok(netdev) &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3971
		    (hw->mac_type == e1000_80003es2lan)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3972
			/* disable receives */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3973
			rctl = er32(RCTL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3974
			ew32(RCTL, rctl & ~E1000_RCTL_EN);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3975
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3976
		/* guard against interrupt when we're going down */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3977
		if (!test_bit(__E1000_DOWN, &adapter->flags))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3978
			mod_timer(&adapter->watchdog_timer, jiffies + 1);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3979
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3980
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3981
	if (adapter->ecdev) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3982
		int i, ec_work_done = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3983
		for (i = 0; i < E1000_MAX_INTR; i++) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3984
			if (unlikely(!adapter->clean_rx(adapter, adapter->rx_ring,
2050
a3e59f2a8589 Changed accidentally used & operator to &&.
Florian Pose <fp@igh-essen.com>
parents: 1900
diff changeset
  3985
							 &ec_work_done, 100) &&
1900
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3986
						!e1000_clean_tx_irq(adapter, adapter->tx_ring))) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3987
				break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3988
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3989
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3990
	} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3991
		if (unlikely(hw->mac_type < e1000_82571)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3992
			/* disable interrupts, without the synchronize_irq bit */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3993
			ew32(IMC, ~0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3994
			E1000_WRITE_FLUSH();
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3995
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3996
		if (likely(netif_rx_schedule_prep(netdev, &adapter->napi))) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3997
			adapter->total_tx_bytes = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3998
			adapter->total_tx_packets = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3999
			adapter->total_rx_bytes = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4000
			adapter->total_rx_packets = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4001
			__netif_rx_schedule(netdev, &adapter->napi);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4002
		} else
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4003
			/* this really should not happen! if it does it is basically a
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4004
			 * bug, but not a hard error, so enable ints and continue */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4005
			e1000_irq_enable(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4006
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4007
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4008
	return IRQ_HANDLED;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4009
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4010
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4011
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4012
 * e1000_clean - NAPI Rx polling callback
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4013
 * @adapter: board private structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4014
 * EtherCAT: never called
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4015
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4016
static int e1000_clean(struct napi_struct *napi, int budget)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4017
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4018
	struct e1000_adapter *adapter = container_of(napi, struct e1000_adapter, napi);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4019
	struct net_device *poll_dev = adapter->netdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4020
	int tx_cleaned = 0, work_done = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4021
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4022
	/* Must NOT use netdev_priv macro here. */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4023
	adapter = poll_dev->priv;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4024
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4025
	/* e1000_clean is called per-cpu.  This lock protects
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4026
	 * tx_ring[0] from being cleaned by multiple cpus
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4027
	 * simultaneously.  A failure obtaining the lock means
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4028
	 * tx_ring[0] is currently being cleaned anyway. */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4029
	if (spin_trylock(&adapter->tx_queue_lock)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4030
		tx_cleaned = e1000_clean_tx_irq(adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4031
						&adapter->tx_ring[0]);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4032
		spin_unlock(&adapter->tx_queue_lock);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4033
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4034
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4035
	adapter->clean_rx(adapter, &adapter->rx_ring[0],
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4036
	                  &work_done, budget);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4037
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4038
	if (tx_cleaned)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4039
		work_done = budget;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4040
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4041
	/* If budget not fully consumed, exit the polling mode */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4042
	if (work_done < budget) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4043
		if (likely(adapter->itr_setting & 3))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4044
			e1000_set_itr(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4045
		netif_rx_complete(poll_dev, napi);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4046
		e1000_irq_enable(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4047
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4048
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4049
	return work_done;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4050
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4051
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4052
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4053
 * e1000_clean_tx_irq - Reclaim resources after transmit completes
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4054
 * @adapter: board private structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4055
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4056
static bool e1000_clean_tx_irq(struct e1000_adapter *adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4057
			       struct e1000_tx_ring *tx_ring)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4058
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4059
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4060
	struct net_device *netdev = adapter->netdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4061
	struct e1000_tx_desc *tx_desc, *eop_desc;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4062
	struct e1000_buffer *buffer_info;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4063
	unsigned int i, eop;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4064
	unsigned int count = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4065
	bool cleaned = false;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4066
	unsigned int total_tx_bytes=0, total_tx_packets=0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4067
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4068
	i = tx_ring->next_to_clean;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4069
	eop = tx_ring->buffer_info[i].next_to_watch;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4070
	eop_desc = E1000_TX_DESC(*tx_ring, eop);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4071
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4072
	while (eop_desc->upper.data & cpu_to_le32(E1000_TXD_STAT_DD)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4073
		for (cleaned = false; !cleaned; ) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4074
			tx_desc = E1000_TX_DESC(*tx_ring, i);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4075
			buffer_info = &tx_ring->buffer_info[i];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4076
			cleaned = (i == eop);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4077
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4078
			if (cleaned) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4079
				struct sk_buff *skb = buffer_info->skb;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4080
				unsigned int segs, bytecount;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4081
				segs = skb_shinfo(skb)->gso_segs ?: 1;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4082
				/* multiply data chunks by size of headers */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4083
				bytecount = ((segs - 1) * skb_headlen(skb)) +
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4084
				            skb->len;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4085
				total_tx_packets += segs;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4086
				total_tx_bytes += bytecount;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4087
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4088
			e1000_unmap_and_free_tx_resource(adapter, buffer_info);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4089
			tx_desc->upper.data = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4090
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4091
			if (unlikely(++i == tx_ring->count)) i = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4092
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4093
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4094
		eop = tx_ring->buffer_info[i].next_to_watch;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4095
		eop_desc = E1000_TX_DESC(*tx_ring, eop);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4096
#define E1000_TX_WEIGHT 64
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4097
		/* weight of a sort for tx, to avoid endless transmit cleanup */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4098
		if (count++ == E1000_TX_WEIGHT)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4099
			break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4100
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4101
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4102
	tx_ring->next_to_clean = i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4103
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4104
#define TX_WAKE_THRESHOLD 32
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4105
	if (!adapter->ecdev && unlikely(cleaned && netif_carrier_ok(netdev) &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4106
		     E1000_DESC_UNUSED(tx_ring) >= TX_WAKE_THRESHOLD)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4107
		/* Make sure that anybody stopping the queue after this
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4108
		 * sees the new next_to_clean.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4109
		 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4110
		smp_mb();
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4111
		if (netif_queue_stopped(netdev)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4112
			netif_wake_queue(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4113
			++adapter->restart_queue;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4114
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4115
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4116
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4117
	if (!adapter->ecdev && adapter->detect_tx_hung) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4118
		/* Detect a transmit hang in hardware, this serializes the
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4119
		 * check with the clearing of time_stamp and movement of i */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4120
		adapter->detect_tx_hung = false;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4121
		if (tx_ring->buffer_info[eop].dma &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4122
		    time_after(jiffies, tx_ring->buffer_info[eop].time_stamp +
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4123
		               (adapter->tx_timeout_factor * HZ))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4124
		    && !(er32(STATUS) & E1000_STATUS_TXOFF)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4125
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4126
			/* detected Tx unit hang */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4127
			DPRINTK(DRV, ERR, "Detected Tx Unit Hang\n"
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4128
					"  Tx Queue             <%lu>\n"
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4129
					"  TDH                  <%x>\n"
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4130
					"  TDT                  <%x>\n"
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4131
					"  next_to_use          <%x>\n"
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4132
					"  next_to_clean        <%x>\n"
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4133
					"buffer_info[next_to_clean]\n"
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4134
					"  time_stamp           <%lx>\n"
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4135
					"  next_to_watch        <%x>\n"
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4136
					"  jiffies              <%lx>\n"
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4137
					"  next_to_watch.status <%x>\n",
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4138
				(unsigned long)((tx_ring - adapter->tx_ring) /
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4139
					sizeof(struct e1000_tx_ring)),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4140
				readl(hw->hw_addr + tx_ring->tdh),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4141
				readl(hw->hw_addr + tx_ring->tdt),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4142
				tx_ring->next_to_use,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4143
				tx_ring->next_to_clean,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4144
				tx_ring->buffer_info[eop].time_stamp,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4145
				eop,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4146
				jiffies,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4147
				eop_desc->upper.fields.status);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4148
			netif_stop_queue(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4149
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4150
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4151
	adapter->total_tx_bytes += total_tx_bytes;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4152
	adapter->total_tx_packets += total_tx_packets;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4153
	adapter->net_stats.tx_bytes += total_tx_bytes;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4154
	adapter->net_stats.tx_packets += total_tx_packets;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4155
	return cleaned;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4156
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4157
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4158
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4159
 * e1000_rx_checksum - Receive Checksum Offload for 82543
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4160
 * @adapter:     board private structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4161
 * @status_err:  receive descriptor status and error fields
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4162
 * @csum:        receive descriptor csum field
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4163
 * @sk_buff:     socket buffer with received data
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4164
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4165
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4166
static void e1000_rx_checksum(struct e1000_adapter *adapter, u32 status_err,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4167
			      u32 csum, struct sk_buff *skb)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4168
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4169
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4170
	u16 status = (u16)status_err;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4171
	u8 errors = (u8)(status_err >> 24);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4172
	skb->ip_summed = CHECKSUM_NONE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4173
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4174
	/* 82543 or newer only */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4175
	if (unlikely(hw->mac_type < e1000_82543)) return;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4176
	/* Ignore Checksum bit is set */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4177
	if (unlikely(status & E1000_RXD_STAT_IXSM)) return;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4178
	/* TCP/UDP checksum error bit is set */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4179
	if (unlikely(errors & E1000_RXD_ERR_TCPE)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4180
		/* let the stack verify checksum errors */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4181
		adapter->hw_csum_err++;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4182
		return;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4183
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4184
	/* TCP/UDP Checksum has not been calculated */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4185
	if (hw->mac_type <= e1000_82547_rev_2) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4186
		if (!(status & E1000_RXD_STAT_TCPCS))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4187
			return;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4188
	} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4189
		if (!(status & (E1000_RXD_STAT_TCPCS | E1000_RXD_STAT_UDPCS)))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4190
			return;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4191
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4192
	/* It must be a TCP or UDP packet with a valid checksum */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4193
	if (likely(status & E1000_RXD_STAT_TCPCS)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4194
		/* TCP checksum is good */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4195
		skb->ip_summed = CHECKSUM_UNNECESSARY;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4196
	} else if (hw->mac_type > e1000_82547_rev_2) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4197
		/* IP fragment with UDP payload */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4198
		/* Hardware complements the payload checksum, so we undo it
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4199
		 * and then put the value in host order for further stack use.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4200
		 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4201
		__sum16 sum = (__force __sum16)htons(csum);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4202
		skb->csum = csum_unfold(~sum);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4203
		skb->ip_summed = CHECKSUM_COMPLETE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4204
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4205
	adapter->hw_csum_good++;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4206
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4207
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4208
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4209
 * e1000_clean_rx_irq - Send received data up the network stack; legacy
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4210
 * @adapter: board private structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4211
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4212
static bool e1000_clean_rx_irq(struct e1000_adapter *adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4213
			       struct e1000_rx_ring *rx_ring,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4214
			       int *work_done, int work_to_do)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4215
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4216
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4217
	struct net_device *netdev = adapter->netdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4218
	struct pci_dev *pdev = adapter->pdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4219
	struct e1000_rx_desc *rx_desc, *next_rxd;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4220
	struct e1000_buffer *buffer_info, *next_buffer;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4221
	unsigned long flags;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4222
	u32 length;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4223
	u8 last_byte;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4224
	unsigned int i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4225
	int cleaned_count = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4226
	bool cleaned = false;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4227
	unsigned int total_rx_bytes=0, total_rx_packets=0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4228
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4229
	i = rx_ring->next_to_clean;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4230
	rx_desc = E1000_RX_DESC(*rx_ring, i);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4231
	buffer_info = &rx_ring->buffer_info[i];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4232
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4233
	while (rx_desc->status & E1000_RXD_STAT_DD) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4234
		struct sk_buff *skb;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4235
		u8 status;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4236
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4237
		if (*work_done >= work_to_do)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4238
			break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4239
		(*work_done)++;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4240
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4241
		status = rx_desc->status;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4242
		skb = buffer_info->skb;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4243
		if (!adapter->ecdev) buffer_info->skb = NULL;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4244
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4245
		prefetch(skb->data - NET_IP_ALIGN);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4246
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4247
		if (++i == rx_ring->count) i = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4248
		next_rxd = E1000_RX_DESC(*rx_ring, i);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4249
		prefetch(next_rxd);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4250
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4251
		next_buffer = &rx_ring->buffer_info[i];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4252
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4253
		cleaned = true;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4254
		cleaned_count++;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4255
		pci_unmap_single(pdev,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4256
		                 buffer_info->dma,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4257
		                 buffer_info->length,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4258
		                 PCI_DMA_FROMDEVICE);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4259
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4260
		length = le16_to_cpu(rx_desc->length);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4261
		/* !EOP means multiple descriptors were used to store a single
2252
6001f50617a7 Added changes in e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents: 2050
diff changeset
  4262
		 * packet, also make sure the frame isn't just CRC only */
6001f50617a7 Added changes in e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents: 2050
diff changeset
  4263
		if (unlikely(!(status & E1000_RXD_STAT_EOP) || (length <= 4))) {
1900
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4264
			/* All receives must fit into a single buffer */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4265
			E1000_DBG("%s: Receive packet consumed multiple"
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4266
				  " buffers\n", netdev->name);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4267
			/* recycle */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4268
			buffer_info->skb = skb;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4269
			goto next_desc;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4270
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4271
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4272
		if (!adapter->ecdev &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4273
                unlikely(rx_desc->errors & E1000_RXD_ERR_FRAME_ERR_MASK)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4274
			last_byte = *(skb->data + length - 1);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4275
			if (TBI_ACCEPT(hw, status, rx_desc->errors, length,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4276
				       last_byte)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4277
				spin_lock_irqsave(&adapter->stats_lock, flags);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4278
				e1000_tbi_adjust_stats(hw, &adapter->stats,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4279
				                       length, skb->data);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4280
				spin_unlock_irqrestore(&adapter->stats_lock,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4281
				                       flags);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4282
				length--;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4283
			} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4284
				/* recycle */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4285
				buffer_info->skb = skb;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4286
				goto next_desc;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4287
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4288
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4289
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4290
		/* adjust length to remove Ethernet CRC, this must be
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4291
		 * done after the TBI_ACCEPT workaround above */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4292
		length -= 4;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4293
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4294
		/* probably a little skewed due to removing CRC */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4295
		total_rx_bytes += length;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4296
		total_rx_packets++;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4297
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4298
		/* code added for copybreak, this should improve
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4299
		 * performance for small packets with large amounts
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4300
		 * of reassembly being done in the stack */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4301
		if (!adapter->ecdev && length < copybreak) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4302
			struct sk_buff *new_skb =
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4303
			    netdev_alloc_skb(netdev, length + NET_IP_ALIGN);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4304
			if (new_skb) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4305
				skb_reserve(new_skb, NET_IP_ALIGN);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4306
				skb_copy_to_linear_data_offset(new_skb,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4307
							       -NET_IP_ALIGN,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4308
							       (skb->data -
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4309
							        NET_IP_ALIGN),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4310
							       (length +
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4311
							        NET_IP_ALIGN));
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4312
				/* save the skb in buffer_info as good */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4313
				buffer_info->skb = skb;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4314
				skb = new_skb;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4315
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4316
			/* else just continue with the old one */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4317
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4318
		/* end copybreak code */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4319
		skb_put(skb, length);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4320
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4321
		/* Receive Checksum Offload */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4322
		e1000_rx_checksum(adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4323
				  (u32)(status) |
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4324
				  ((u32)(rx_desc->errors) << 24),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4325
				  le16_to_cpu(rx_desc->csum), skb);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4326
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4327
		if (adapter->ecdev) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4328
			ecdev_receive(adapter->ecdev, skb->data, length);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4329
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4330
			// No need to detect link status as
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4331
			// long as frames are received: Reset watchdog.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4332
			adapter->ec_watchdog_jiffies = jiffies;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4333
		} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4334
			skb->protocol = eth_type_trans(skb, netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4335
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4336
			if (unlikely(adapter->vlgrp &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4337
						(status & E1000_RXD_STAT_VP))) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4338
				vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4339
						le16_to_cpu(rx_desc->special));
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4340
			} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4341
				netif_receive_skb(skb);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4342
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4343
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4344
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4345
		netdev->last_rx = jiffies;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4346
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4347
next_desc:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4348
		rx_desc->status = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4349
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4350
		/* return some buffers to hardware, one at a time is too slow */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4351
		if (unlikely(cleaned_count >= E1000_RX_BUFFER_WRITE)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4352
			adapter->alloc_rx_buf(adapter, rx_ring, cleaned_count);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4353
			cleaned_count = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4354
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4355
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4356
		/* use prefetched values */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4357
		rx_desc = next_rxd;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4358
		buffer_info = next_buffer;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4359
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4360
	rx_ring->next_to_clean = i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4361
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4362
	cleaned_count = E1000_DESC_UNUSED(rx_ring);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4363
	if (cleaned_count)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4364
		adapter->alloc_rx_buf(adapter, rx_ring, cleaned_count);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4365
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4366
	adapter->total_rx_packets += total_rx_packets;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4367
	adapter->total_rx_bytes += total_rx_bytes;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4368
	adapter->net_stats.rx_bytes += total_rx_bytes;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4369
	adapter->net_stats.rx_packets += total_rx_packets;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4370
	return cleaned;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4371
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4372
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4373
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4374
 * e1000_clean_rx_irq_ps - Send received data up the network stack; packet split
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4375
 * @adapter: board private structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4376
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4377
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4378
static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4379
				  struct e1000_rx_ring *rx_ring,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4380
				  int *work_done, int work_to_do)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4381
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4382
	union e1000_rx_desc_packet_split *rx_desc, *next_rxd;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4383
	struct net_device *netdev = adapter->netdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4384
	struct pci_dev *pdev = adapter->pdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4385
	struct e1000_buffer *buffer_info, *next_buffer;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4386
	struct e1000_ps_page *ps_page;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4387
	struct e1000_ps_page_dma *ps_page_dma;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4388
	struct sk_buff *skb;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4389
	unsigned int i, j;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4390
	u32 length, staterr;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4391
	int cleaned_count = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4392
	bool cleaned = false;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4393
	unsigned int total_rx_bytes=0, total_rx_packets=0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4394
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4395
	i = rx_ring->next_to_clean;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4396
	rx_desc = E1000_RX_DESC_PS(*rx_ring, i);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4397
	staterr = le32_to_cpu(rx_desc->wb.middle.status_error);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4398
	buffer_info = &rx_ring->buffer_info[i];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4399
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4400
	while (staterr & E1000_RXD_STAT_DD) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4401
		ps_page = &rx_ring->ps_page[i];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4402
		ps_page_dma = &rx_ring->ps_page_dma[i];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4403
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4404
		if (unlikely(*work_done >= work_to_do))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4405
			break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4406
		(*work_done)++;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4407
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4408
		skb = buffer_info->skb;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4409
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4410
		/* in the packet split case this is header only */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4411
		prefetch(skb->data - NET_IP_ALIGN);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4412
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4413
		if (++i == rx_ring->count) i = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4414
		next_rxd = E1000_RX_DESC_PS(*rx_ring, i);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4415
		prefetch(next_rxd);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4416
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4417
		next_buffer = &rx_ring->buffer_info[i];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4418
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4419
		cleaned = true;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4420
		cleaned_count++;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4421
		pci_unmap_single(pdev, buffer_info->dma,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4422
				 buffer_info->length,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4423
				 PCI_DMA_FROMDEVICE);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4424
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4425
		if (unlikely(!(staterr & E1000_RXD_STAT_EOP))) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4426
			E1000_DBG("%s: Packet Split buffers didn't pick up"
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4427
				  " the full packet\n", netdev->name);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4428
			if (!adapter->ecdev) dev_kfree_skb_irq(skb);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4429
			goto next_desc;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4430
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4431
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4432
		if (unlikely(staterr & E1000_RXDEXT_ERR_FRAME_ERR_MASK)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4433
			if (!adapter->ecdev) dev_kfree_skb_irq(skb);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4434
			goto next_desc;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4435
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4436
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4437
		length = le16_to_cpu(rx_desc->wb.middle.length0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4438
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4439
		if (unlikely(!length)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4440
			E1000_DBG("%s: Last part of the packet spanning"
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4441
				  " multiple descriptors\n", netdev->name);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4442
			if (!adapter->ecdev) dev_kfree_skb_irq(skb);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4443
			goto next_desc;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4444
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4445
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4446
		/* Good Receive */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4447
		skb_put(skb, length);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4448
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4449
		{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4450
		/* this looks ugly, but it seems compiler issues make it
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4451
		   more efficient than reusing j */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4452
		int l1 = le16_to_cpu(rx_desc->wb.upper.length[0]);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4453
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4454
		/* page alloc/put takes too long and effects small packet
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4455
		 * throughput, so unsplit small packets and save the alloc/put*/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4456
		if (l1 && (l1 <= copybreak) && ((length + l1) <= adapter->rx_ps_bsize0)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4457
			u8 *vaddr;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4458
			/* there is no documentation about how to call
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4459
			 * kmap_atomic, so we can't hold the mapping
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4460
			 * very long */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4461
			pci_dma_sync_single_for_cpu(pdev,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4462
				ps_page_dma->ps_page_dma[0],
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4463
				PAGE_SIZE,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4464
				PCI_DMA_FROMDEVICE);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4465
			vaddr = kmap_atomic(ps_page->ps_page[0],
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4466
			                    KM_SKB_DATA_SOFTIRQ);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4467
			memcpy(skb_tail_pointer(skb), vaddr, l1);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4468
			kunmap_atomic(vaddr, KM_SKB_DATA_SOFTIRQ);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4469
			pci_dma_sync_single_for_device(pdev,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4470
				ps_page_dma->ps_page_dma[0],
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4471
				PAGE_SIZE, PCI_DMA_FROMDEVICE);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4472
			/* remove the CRC */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4473
			l1 -= 4;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4474
			skb_put(skb, l1);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4475
			goto copydone;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4476
		} /* if */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4477
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4478
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4479
		for (j = 0; j < adapter->rx_ps_pages; j++) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4480
			length = le16_to_cpu(rx_desc->wb.upper.length[j]);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4481
			if (!length)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4482
				break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4483
			pci_unmap_page(pdev, ps_page_dma->ps_page_dma[j],
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4484
					PAGE_SIZE, PCI_DMA_FROMDEVICE);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4485
			ps_page_dma->ps_page_dma[j] = 0;
2252
6001f50617a7 Added changes in e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents: 2050
diff changeset
  4486
			skb_fill_page_desc(skb, j, ps_page->ps_page[j], 0,
6001f50617a7 Added changes in e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents: 2050
diff changeset
  4487
			                   length);
1900
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4488
			ps_page->ps_page[j] = NULL;
2252
6001f50617a7 Added changes in e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents: 2050
diff changeset
  4489
			skb->len += length;
6001f50617a7 Added changes in e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents: 2050
diff changeset
  4490
			skb->data_len += length;
6001f50617a7 Added changes in e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents: 2050
diff changeset
  4491
			skb->truesize += length;
1900
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4492
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4493
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4494
		/* strip the ethernet crc, problem is we're using pages now so
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4495
		 * this whole operation can get a little cpu intensive */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4496
		pskb_trim(skb, skb->len - 4);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4497
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4498
copydone:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4499
		total_rx_bytes += skb->len;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4500
		total_rx_packets++;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4501
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4502
		e1000_rx_checksum(adapter, staterr,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4503
				  le16_to_cpu(rx_desc->wb.lower.hi_dword.csum_ip.csum), skb);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4504
		if (adapter->ecdev) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4505
			ecdev_receive(adapter->ecdev, skb->data, length);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4506
		} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4507
			skb->protocol = eth_type_trans(skb, netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4508
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4509
			if (likely(rx_desc->wb.upper.header_status &
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4510
				   cpu_to_le16(E1000_RXDPS_HDRSTAT_HDRSP)))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4511
				adapter->rx_hdr_split++;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4512
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4513
			if (unlikely(adapter->vlgrp && (staterr & E1000_RXD_STAT_VP))) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4514
				vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4515
					le16_to_cpu(rx_desc->wb.middle.vlan));
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4516
			} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4517
				netif_receive_skb(skb);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4518
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4519
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4520
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4521
		netdev->last_rx = jiffies;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4522
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4523
next_desc:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4524
		rx_desc->wb.middle.status_error &= cpu_to_le32(~0xFF);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4525
 		if (!adapter->ecdev) buffer_info->skb = NULL;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4526
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4527
		/* return some buffers to hardware, one at a time is too slow */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4528
		if (unlikely(cleaned_count >= E1000_RX_BUFFER_WRITE)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4529
			adapter->alloc_rx_buf(adapter, rx_ring, cleaned_count);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4530
			cleaned_count = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4531
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4532
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4533
		/* use prefetched values */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4534
		rx_desc = next_rxd;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4535
		buffer_info = next_buffer;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4536
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4537
		staterr = le32_to_cpu(rx_desc->wb.middle.status_error);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4538
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4539
	rx_ring->next_to_clean = i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4540
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4541
	cleaned_count = E1000_DESC_UNUSED(rx_ring);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4542
	if (cleaned_count)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4543
		adapter->alloc_rx_buf(adapter, rx_ring, cleaned_count);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4544
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4545
	adapter->total_rx_packets += total_rx_packets;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4546
	adapter->total_rx_bytes += total_rx_bytes;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4547
	adapter->net_stats.rx_bytes += total_rx_bytes;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4548
	adapter->net_stats.rx_packets += total_rx_packets;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4549
	return cleaned;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4550
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4551
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4552
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4553
 * e1000_alloc_rx_buffers - Replace used receive buffers; legacy & extended
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4554
 * @adapter: address of board private structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4555
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4556
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4557
static void e1000_alloc_rx_buffers(struct e1000_adapter *adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4558
				   struct e1000_rx_ring *rx_ring,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4559
				   int cleaned_count)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4560
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4561
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4562
	struct net_device *netdev = adapter->netdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4563
	struct pci_dev *pdev = adapter->pdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4564
	struct e1000_rx_desc *rx_desc;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4565
	struct e1000_buffer *buffer_info;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4566
	struct sk_buff *skb;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4567
	unsigned int i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4568
	unsigned int bufsz = adapter->rx_buffer_len + NET_IP_ALIGN;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4569
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4570
	i = rx_ring->next_to_use;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4571
	buffer_info = &rx_ring->buffer_info[i];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4572
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4573
	while (cleaned_count--) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4574
		skb = buffer_info->skb;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4575
		if (skb) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4576
			skb_trim(skb, 0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4577
			goto map_skb;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4578
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4579
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4580
		skb = netdev_alloc_skb(netdev, bufsz);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4581
		if (unlikely(!skb)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4582
			/* Better luck next round */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4583
			adapter->alloc_rx_buff_failed++;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4584
			break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4585
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4586
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4587
		/* Fix for errata 23, can't cross 64kB boundary */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4588
		if (!e1000_check_64k_bound(adapter, skb->data, bufsz)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4589
			struct sk_buff *oldskb = skb;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4590
			DPRINTK(RX_ERR, ERR, "skb align check failed: %u bytes "
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4591
					     "at %p\n", bufsz, skb->data);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4592
			/* Try again, without freeing the previous */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4593
			skb = netdev_alloc_skb(netdev, bufsz);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4594
			/* Failed allocation, critical failure */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4595
			if (!skb) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4596
				dev_kfree_skb(oldskb);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4597
				break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4598
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4599
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4600
			if (!e1000_check_64k_bound(adapter, skb->data, bufsz)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4601
				/* give up */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4602
				dev_kfree_skb(skb);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4603
				dev_kfree_skb(oldskb);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4604
				break; /* while !buffer_info->skb */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4605
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4606
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4607
			/* Use new allocation */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4608
			dev_kfree_skb(oldskb);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4609
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4610
		/* Make buffer alignment 2 beyond a 16 byte boundary
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4611
		 * this will result in a 16 byte aligned IP header after
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4612
		 * the 14 byte MAC header is removed
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4613
		 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4614
		skb_reserve(skb, NET_IP_ALIGN);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4615
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4616
		buffer_info->skb = skb;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4617
		buffer_info->length = adapter->rx_buffer_len;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4618
map_skb:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4619
		buffer_info->dma = pci_map_single(pdev,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4620
						  skb->data,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4621
						  adapter->rx_buffer_len,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4622
						  PCI_DMA_FROMDEVICE);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4623
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4624
		/* Fix for errata 23, can't cross 64kB boundary */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4625
		if (!e1000_check_64k_bound(adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4626
					(void *)(unsigned long)buffer_info->dma,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4627
					adapter->rx_buffer_len)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4628
			DPRINTK(RX_ERR, ERR,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4629
				"dma align check failed: %u bytes at %p\n",
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4630
				adapter->rx_buffer_len,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4631
				(void *)(unsigned long)buffer_info->dma);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4632
			if (!adapter->ecdev) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4633
				dev_kfree_skb(skb);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4634
				buffer_info->skb = NULL;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4635
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4636
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4637
			pci_unmap_single(pdev, buffer_info->dma,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4638
					 adapter->rx_buffer_len,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4639
					 PCI_DMA_FROMDEVICE);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4640
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4641
			break; /* while !buffer_info->skb */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4642
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4643
		rx_desc = E1000_RX_DESC(*rx_ring, i);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4644
		rx_desc->buffer_addr = cpu_to_le64(buffer_info->dma);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4645
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4646
		if (unlikely(++i == rx_ring->count))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4647
			i = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4648
		buffer_info = &rx_ring->buffer_info[i];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4649
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4650
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4651
	if (likely(rx_ring->next_to_use != i)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4652
		rx_ring->next_to_use = i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4653
		if (unlikely(i-- == 0))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4654
			i = (rx_ring->count - 1);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4655
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4656
		/* Force memory writes to complete before letting h/w
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4657
		 * know there are new descriptors to fetch.  (Only
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4658
		 * applicable for weak-ordered memory model archs,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4659
		 * such as IA-64). */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4660
		wmb();
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4661
		writel(i, hw->hw_addr + rx_ring->rdt);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4662
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4663
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4664
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4665
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4666
 * e1000_alloc_rx_buffers_ps - Replace used receive buffers; packet split
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4667
 * @adapter: address of board private structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4668
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4669
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4670
static void e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4671
				      struct e1000_rx_ring *rx_ring,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4672
				      int cleaned_count)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4673
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4674
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4675
	struct net_device *netdev = adapter->netdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4676
	struct pci_dev *pdev = adapter->pdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4677
	union e1000_rx_desc_packet_split *rx_desc;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4678
	struct e1000_buffer *buffer_info;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4679
	struct e1000_ps_page *ps_page;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4680
	struct e1000_ps_page_dma *ps_page_dma;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4681
	struct sk_buff *skb;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4682
	unsigned int i, j;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4683
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4684
	i = rx_ring->next_to_use;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4685
	buffer_info = &rx_ring->buffer_info[i];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4686
	ps_page = &rx_ring->ps_page[i];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4687
	ps_page_dma = &rx_ring->ps_page_dma[i];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4688
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4689
	while (cleaned_count--) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4690
		rx_desc = E1000_RX_DESC_PS(*rx_ring, i);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4691
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4692
		for (j = 0; j < PS_PAGE_BUFFERS; j++) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4693
			if (j < adapter->rx_ps_pages) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4694
				if (likely(!ps_page->ps_page[j])) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4695
					ps_page->ps_page[j] =
2252
6001f50617a7 Added changes in e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents: 2050
diff changeset
  4696
						alloc_page(GFP_ATOMIC);
1900
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4697
					if (unlikely(!ps_page->ps_page[j])) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4698
						adapter->alloc_rx_buff_failed++;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4699
						goto no_buffers;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4700
					}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4701
					ps_page_dma->ps_page_dma[j] =
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4702
						pci_map_page(pdev,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4703
							    ps_page->ps_page[j],
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4704
							    0, PAGE_SIZE,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4705
							    PCI_DMA_FROMDEVICE);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4706
				}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4707
				/* Refresh the desc even if buffer_addrs didn't
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4708
				 * change because each write-back erases
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4709
				 * this info.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4710
				 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4711
				rx_desc->read.buffer_addr[j+1] =
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4712
				     cpu_to_le64(ps_page_dma->ps_page_dma[j]);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4713
			} else
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4714
				rx_desc->read.buffer_addr[j+1] = ~cpu_to_le64(0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4715
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4716
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4717
		skb = netdev_alloc_skb(netdev,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4718
		                       adapter->rx_ps_bsize0 + NET_IP_ALIGN);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4719
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4720
		if (unlikely(!skb)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4721
			adapter->alloc_rx_buff_failed++;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4722
			break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4723
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4724
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4725
		/* Make buffer alignment 2 beyond a 16 byte boundary
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4726
		 * this will result in a 16 byte aligned IP header after
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4727
		 * the 14 byte MAC header is removed
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4728
		 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4729
		skb_reserve(skb, NET_IP_ALIGN);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4730
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4731
		buffer_info->skb = skb;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4732
		buffer_info->length = adapter->rx_ps_bsize0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4733
		buffer_info->dma = pci_map_single(pdev, skb->data,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4734
						  adapter->rx_ps_bsize0,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4735
						  PCI_DMA_FROMDEVICE);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4736
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4737
		rx_desc->read.buffer_addr[0] = cpu_to_le64(buffer_info->dma);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4738
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4739
		if (unlikely(++i == rx_ring->count)) i = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4740
		buffer_info = &rx_ring->buffer_info[i];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4741
		ps_page = &rx_ring->ps_page[i];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4742
		ps_page_dma = &rx_ring->ps_page_dma[i];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4743
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4744
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4745
no_buffers:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4746
	if (likely(rx_ring->next_to_use != i)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4747
		rx_ring->next_to_use = i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4748
		if (unlikely(i-- == 0)) i = (rx_ring->count - 1);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4749
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4750
		/* Force memory writes to complete before letting h/w
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4751
		 * know there are new descriptors to fetch.  (Only
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4752
		 * applicable for weak-ordered memory model archs,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4753
		 * such as IA-64). */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4754
		wmb();
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4755
		/* Hardware increments by 16 bytes, but packet split
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4756
		 * descriptors are 32 bytes...so we increment tail
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4757
		 * twice as much.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4758
		 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4759
		writel(i<<1, hw->hw_addr + rx_ring->rdt);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4760
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4761
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4762
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4763
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4764
 * e1000_smartspeed - Workaround for SmartSpeed on 82541 and 82547 controllers.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4765
 * @adapter:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4766
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4767
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4768
static void e1000_smartspeed(struct e1000_adapter *adapter)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4769
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4770
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4771
	u16 phy_status;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4772
	u16 phy_ctrl;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4773
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4774
	if ((hw->phy_type != e1000_phy_igp) || !hw->autoneg ||
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4775
	   !(hw->autoneg_advertised & ADVERTISE_1000_FULL))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4776
		return;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4777
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4778
	if (adapter->smartspeed == 0) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4779
		/* If Master/Slave config fault is asserted twice,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4780
		 * we assume back-to-back */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4781
		e1000_read_phy_reg(hw, PHY_1000T_STATUS, &phy_status);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4782
		if (!(phy_status & SR_1000T_MS_CONFIG_FAULT)) return;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4783
		e1000_read_phy_reg(hw, PHY_1000T_STATUS, &phy_status);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4784
		if (!(phy_status & SR_1000T_MS_CONFIG_FAULT)) return;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4785
		e1000_read_phy_reg(hw, PHY_1000T_CTRL, &phy_ctrl);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4786
		if (phy_ctrl & CR_1000T_MS_ENABLE) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4787
			phy_ctrl &= ~CR_1000T_MS_ENABLE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4788
			e1000_write_phy_reg(hw, PHY_1000T_CTRL,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4789
					    phy_ctrl);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4790
			adapter->smartspeed++;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4791
			if (!e1000_phy_setup_autoneg(hw) &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4792
			   !e1000_read_phy_reg(hw, PHY_CTRL,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4793
				   	       &phy_ctrl)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4794
				phy_ctrl |= (MII_CR_AUTO_NEG_EN |
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4795
					     MII_CR_RESTART_AUTO_NEG);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4796
				e1000_write_phy_reg(hw, PHY_CTRL,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4797
						    phy_ctrl);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4798
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4799
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4800
		return;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4801
	} else if (adapter->smartspeed == E1000_SMARTSPEED_DOWNSHIFT) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4802
		/* If still no link, perhaps using 2/3 pair cable */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4803
		e1000_read_phy_reg(hw, PHY_1000T_CTRL, &phy_ctrl);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4804
		phy_ctrl |= CR_1000T_MS_ENABLE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4805
		e1000_write_phy_reg(hw, PHY_1000T_CTRL, phy_ctrl);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4806
		if (!e1000_phy_setup_autoneg(hw) &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4807
		   !e1000_read_phy_reg(hw, PHY_CTRL, &phy_ctrl)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4808
			phy_ctrl |= (MII_CR_AUTO_NEG_EN |
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4809
				     MII_CR_RESTART_AUTO_NEG);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4810
			e1000_write_phy_reg(hw, PHY_CTRL, phy_ctrl);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4811
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4812
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4813
	/* Restart process after E1000_SMARTSPEED_MAX iterations */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4814
	if (adapter->smartspeed++ == E1000_SMARTSPEED_MAX)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4815
		adapter->smartspeed = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4816
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4817
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4818
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4819
 * e1000_ioctl -
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4820
 * @netdev:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4821
 * @ifreq:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4822
 * @cmd:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4823
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4824
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4825
static int e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4826
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4827
	switch (cmd) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4828
	case SIOCGMIIPHY:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4829
	case SIOCGMIIREG:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4830
	case SIOCSMIIREG:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4831
		return e1000_mii_ioctl(netdev, ifr, cmd);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4832
	default:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4833
		return -EOPNOTSUPP;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4834
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4835
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4836
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4837
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4838
 * e1000_mii_ioctl -
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4839
 * @netdev:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4840
 * @ifreq:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4841
 * @cmd:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4842
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4843
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4844
static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4845
			   int cmd)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4846
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4847
	struct e1000_adapter *adapter = netdev_priv(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4848
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4849
	struct mii_ioctl_data *data = if_mii(ifr);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4850
	int retval;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4851
	u16 mii_reg;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4852
	u16 spddplx;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4853
	unsigned long flags;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4854
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4855
	if (hw->media_type != e1000_media_type_copper)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4856
		return -EOPNOTSUPP;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4857
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4858
	switch (cmd) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4859
	case SIOCGMIIPHY:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4860
		data->phy_id = hw->phy_addr;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4861
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4862
	case SIOCGMIIREG:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4863
		if (adapter->ecdev || !capable(CAP_NET_ADMIN))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4864
			return -EPERM;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4865
		spin_lock_irqsave(&adapter->stats_lock, flags);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4866
		if (e1000_read_phy_reg(hw, data->reg_num & 0x1F,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4867
				   &data->val_out)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4868
			spin_unlock_irqrestore(&adapter->stats_lock, flags);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4869
			return -EIO;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4870
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4871
		spin_unlock_irqrestore(&adapter->stats_lock, flags);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4872
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4873
	case SIOCSMIIREG:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4874
		if (adapter->ecdev || !capable(CAP_NET_ADMIN))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4875
			return -EPERM;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4876
		if (data->reg_num & ~(0x1F))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4877
			return -EFAULT;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4878
		mii_reg = data->val_in;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4879
		spin_lock_irqsave(&adapter->stats_lock, flags);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4880
		if (e1000_write_phy_reg(hw, data->reg_num,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4881
					mii_reg)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4882
			spin_unlock_irqrestore(&adapter->stats_lock, flags);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4883
			return -EIO;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4884
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4885
		spin_unlock_irqrestore(&adapter->stats_lock, flags);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4886
		if (hw->media_type == e1000_media_type_copper) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4887
			switch (data->reg_num) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4888
			case PHY_CTRL:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4889
				if (mii_reg & MII_CR_POWER_DOWN)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4890
					break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4891
				if (mii_reg & MII_CR_AUTO_NEG_EN) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4892
					hw->autoneg = 1;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4893
					hw->autoneg_advertised = 0x2F;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4894
				} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4895
					if (mii_reg & 0x40)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4896
						spddplx = SPEED_1000;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4897
					else if (mii_reg & 0x2000)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4898
						spddplx = SPEED_100;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4899
					else
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4900
						spddplx = SPEED_10;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4901
					spddplx += (mii_reg & 0x100)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4902
						   ? DUPLEX_FULL :
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4903
						   DUPLEX_HALF;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4904
					retval = e1000_set_spd_dplx(adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4905
								    spddplx);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4906
					if (retval)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4907
						return retval;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4908
				}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4909
				if (netif_running(adapter->netdev))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4910
					e1000_reinit_locked(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4911
				else
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4912
					e1000_reset(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4913
				break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4914
			case M88E1000_PHY_SPEC_CTRL:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4915
			case M88E1000_EXT_PHY_SPEC_CTRL:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4916
				if (e1000_phy_reset(hw))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4917
					return -EIO;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4918
				break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4919
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4920
		} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4921
			switch (data->reg_num) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4922
			case PHY_CTRL:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4923
				if (mii_reg & MII_CR_POWER_DOWN)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4924
					break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4925
				if (netif_running(adapter->netdev))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4926
					e1000_reinit_locked(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4927
				else
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4928
					e1000_reset(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4929
				break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4930
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4931
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4932
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4933
	default:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4934
		return -EOPNOTSUPP;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4935
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4936
	return E1000_SUCCESS;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4937
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4938
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4939
void e1000_pci_set_mwi(struct e1000_hw *hw)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4940
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4941
	struct e1000_adapter *adapter = hw->back;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4942
	int ret_val = pci_set_mwi(adapter->pdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4943
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4944
	if (ret_val)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4945
		DPRINTK(PROBE, ERR, "Error in setting MWI\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4946
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4947
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4948
void e1000_pci_clear_mwi(struct e1000_hw *hw)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4949
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4950
	struct e1000_adapter *adapter = hw->back;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4951
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4952
	pci_clear_mwi(adapter->pdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4953
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4954
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4955
int e1000_pcix_get_mmrbc(struct e1000_hw *hw)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4956
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4957
	struct e1000_adapter *adapter = hw->back;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4958
	return pcix_get_mmrbc(adapter->pdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4959
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4960
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4961
void e1000_pcix_set_mmrbc(struct e1000_hw *hw, int mmrbc)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4962
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4963
	struct e1000_adapter *adapter = hw->back;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4964
	pcix_set_mmrbc(adapter->pdev, mmrbc);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4965
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4966
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4967
s32 e1000_read_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4968
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4969
    struct e1000_adapter *adapter = hw->back;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4970
    u16 cap_offset;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4971
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4972
    cap_offset = pci_find_capability(adapter->pdev, PCI_CAP_ID_EXP);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4973
    if (!cap_offset)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4974
        return -E1000_ERR_CONFIG;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4975
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4976
    pci_read_config_word(adapter->pdev, cap_offset + reg, value);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4977
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4978
    return E1000_SUCCESS;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4979
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4980
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4981
void e1000_io_write(struct e1000_hw *hw, unsigned long port, u32 value)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4982
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4983
	outl(value, port);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4984
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4985
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4986
static void e1000_vlan_rx_register(struct net_device *netdev,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4987
				   struct vlan_group *grp)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4988
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4989
	struct e1000_adapter *adapter = netdev_priv(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4990
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4991
	u32 ctrl, rctl;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4992
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4993
	if (!test_bit(__E1000_DOWN, &adapter->flags))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4994
		e1000_irq_disable(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4995
	adapter->vlgrp = grp;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4996
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4997
	if (grp) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4998
		/* enable VLAN tag insert/strip */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4999
		ctrl = er32(CTRL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5000
		ctrl |= E1000_CTRL_VME;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5001
		ew32(CTRL, ctrl);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5002
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5003
		if (adapter->hw.mac_type != e1000_ich8lan) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5004
			/* enable VLAN receive filtering */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5005
			rctl = er32(RCTL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5006
			rctl &= ~E1000_RCTL_CFIEN;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5007
			ew32(RCTL, rctl);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5008
			e1000_update_mng_vlan(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5009
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5010
	} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5011
		/* disable VLAN tag insert/strip */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5012
		ctrl = er32(CTRL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5013
		ctrl &= ~E1000_CTRL_VME;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5014
		ew32(CTRL, ctrl);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5015
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5016
		if (adapter->hw.mac_type != e1000_ich8lan) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5017
			if (adapter->mng_vlan_id !=
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5018
			    (u16)E1000_MNG_VLAN_NONE) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5019
				e1000_vlan_rx_kill_vid(netdev,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5020
				                       adapter->mng_vlan_id);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5021
				adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5022
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5023
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5024
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5025
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5026
	if (!test_bit(__E1000_DOWN, &adapter->flags))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5027
		e1000_irq_enable(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5028
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5029
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5030
static void e1000_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5031
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5032
	struct e1000_adapter *adapter = netdev_priv(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5033
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5034
	u32 vfta, index;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5035
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5036
	if ((hw->mng_cookie.status &
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5037
	     E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5038
	    (vid == adapter->mng_vlan_id))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5039
		return;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5040
	/* add VID to filter table */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5041
	index = (vid >> 5) & 0x7F;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5042
	vfta = E1000_READ_REG_ARRAY(hw, VFTA, index);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5043
	vfta |= (1 << (vid & 0x1F));
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5044
	e1000_write_vfta(hw, index, vfta);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5045
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5046
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5047
static void e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5048
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5049
	struct e1000_adapter *adapter = netdev_priv(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5050
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5051
	u32 vfta, index;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5052
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5053
	if (!test_bit(__E1000_DOWN, &adapter->flags))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5054
		e1000_irq_disable(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5055
	vlan_group_set_device(adapter->vlgrp, vid, NULL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5056
	if (!test_bit(__E1000_DOWN, &adapter->flags))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5057
		e1000_irq_enable(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5058
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5059
	if ((hw->mng_cookie.status &
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5060
	     E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5061
	    (vid == adapter->mng_vlan_id)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5062
		/* release control to f/w */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5063
		e1000_release_hw_control(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5064
		return;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5065
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5066
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5067
	/* remove VID from filter table */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5068
	index = (vid >> 5) & 0x7F;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5069
	vfta = E1000_READ_REG_ARRAY(hw, VFTA, index);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5070
	vfta &= ~(1 << (vid & 0x1F));
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5071
	e1000_write_vfta(hw, index, vfta);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5072
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5073
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5074
static void e1000_restore_vlan(struct e1000_adapter *adapter)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5075
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5076
	e1000_vlan_rx_register(adapter->netdev, adapter->vlgrp);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5077
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5078
	if (adapter->vlgrp) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5079
		u16 vid;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5080
		for (vid = 0; vid < VLAN_GROUP_ARRAY_LEN; vid++) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5081
			if (!vlan_group_get_device(adapter->vlgrp, vid))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5082
				continue;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5083
			e1000_vlan_rx_add_vid(adapter->netdev, vid);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5084
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5085
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5086
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5087
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5088
int e1000_set_spd_dplx(struct e1000_adapter *adapter, u16 spddplx)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5089
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5090
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5091
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5092
	hw->autoneg = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5093
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5094
	/* Fiber NICs only allow 1000 gbps Full duplex */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5095
	if ((hw->media_type == e1000_media_type_fiber) &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5096
		spddplx != (SPEED_1000 + DUPLEX_FULL)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5097
		DPRINTK(PROBE, ERR, "Unsupported Speed/Duplex configuration\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5098
		return -EINVAL;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5099
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5100
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5101
	switch (spddplx) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5102
	case SPEED_10 + DUPLEX_HALF:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5103
		hw->forced_speed_duplex = e1000_10_half;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5104
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5105
	case SPEED_10 + DUPLEX_FULL:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5106
		hw->forced_speed_duplex = e1000_10_full;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5107
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5108
	case SPEED_100 + DUPLEX_HALF:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5109
		hw->forced_speed_duplex = e1000_100_half;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5110
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5111
	case SPEED_100 + DUPLEX_FULL:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5112
		hw->forced_speed_duplex = e1000_100_full;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5113
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5114
	case SPEED_1000 + DUPLEX_FULL:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5115
		hw->autoneg = 1;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5116
		hw->autoneg_advertised = ADVERTISE_1000_FULL;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5117
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5118
	case SPEED_1000 + DUPLEX_HALF: /* not supported */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5119
	default:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5120
		DPRINTK(PROBE, ERR, "Unsupported Speed/Duplex configuration\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5121
		return -EINVAL;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5122
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5123
	return 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5124
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5125
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5126
static int e1000_suspend(struct pci_dev *pdev, pm_message_t state)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5127
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5128
	struct net_device *netdev = pci_get_drvdata(pdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5129
	struct e1000_adapter *adapter = netdev_priv(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5130
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5131
	u32 ctrl, ctrl_ext, rctl, status;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5132
	u32 wufc = adapter->wol;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5133
#ifdef CONFIG_PM
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5134
	int retval = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5135
#endif
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5136
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5137
	if (adapter->ecdev)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5138
		return -EBUSY;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5139
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5140
	netif_device_detach(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5141
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5142
	if (netif_running(netdev)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5143
		WARN_ON(test_bit(__E1000_RESETTING, &adapter->flags));
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5144
		e1000_down(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5145
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5146
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5147
#ifdef CONFIG_PM
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5148
	retval = pci_save_state(pdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5149
	if (retval)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5150
		return retval;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5151
#endif
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5152
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5153
	status = er32(STATUS);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5154
	if (status & E1000_STATUS_LU)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5155
		wufc &= ~E1000_WUFC_LNKC;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5156
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5157
	if (wufc) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5158
		e1000_setup_rctl(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5159
		e1000_set_rx_mode(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5160
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5161
		/* turn on all-multi mode if wake on multicast is enabled */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5162
		if (wufc & E1000_WUFC_MC) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5163
			rctl = er32(RCTL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5164
			rctl |= E1000_RCTL_MPE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5165
			ew32(RCTL, rctl);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5166
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5167
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5168
		if (hw->mac_type >= e1000_82540) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5169
			ctrl = er32(CTRL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5170
			/* advertise wake from D3Cold */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5171
			#define E1000_CTRL_ADVD3WUC 0x00100000
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5172
			/* phy power management enable */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5173
			#define E1000_CTRL_EN_PHY_PWR_MGMT 0x00200000
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5174
			ctrl |= E1000_CTRL_ADVD3WUC |
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5175
				E1000_CTRL_EN_PHY_PWR_MGMT;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5176
			ew32(CTRL, ctrl);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5177
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5178
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5179
		if (hw->media_type == e1000_media_type_fiber ||
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5180
		   hw->media_type == e1000_media_type_internal_serdes) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5181
			/* keep the laser running in D3 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5182
			ctrl_ext = er32(CTRL_EXT);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5183
			ctrl_ext |= E1000_CTRL_EXT_SDP7_DATA;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5184
			ew32(CTRL_EXT, ctrl_ext);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5185
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5186
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5187
		/* Allow time for pending master requests to run */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5188
		e1000_disable_pciex_master(hw);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5189
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5190
		ew32(WUC, E1000_WUC_PME_EN);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5191
		ew32(WUFC, wufc);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5192
		pci_enable_wake(pdev, PCI_D3hot, 1);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5193
		pci_enable_wake(pdev, PCI_D3cold, 1);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5194
	} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5195
		ew32(WUC, 0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5196
		ew32(WUFC, 0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5197
		pci_enable_wake(pdev, PCI_D3hot, 0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5198
		pci_enable_wake(pdev, PCI_D3cold, 0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5199
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5200
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5201
	e1000_release_manageability(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5202
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5203
	/* make sure adapter isn't asleep if manageability is enabled */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5204
	if (adapter->en_mng_pt) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5205
		pci_enable_wake(pdev, PCI_D3hot, 1);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5206
		pci_enable_wake(pdev, PCI_D3cold, 1);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5207
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5208
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5209
	if (hw->phy_type == e1000_phy_igp_3)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5210
		e1000_phy_powerdown_workaround(hw);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5211
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5212
	if (netif_running(netdev))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5213
		e1000_free_irq(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5214
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5215
	/* Release control of h/w to f/w.  If f/w is AMT enabled, this
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5216
	 * would have already happened in close and is redundant. */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5217
	e1000_release_hw_control(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5218
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5219
	pci_disable_device(pdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5220
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5221
	pci_set_power_state(pdev, pci_choose_state(pdev, state));
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5222
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5223
	return 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5224
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5225
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5226
#ifdef CONFIG_PM
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5227
static int e1000_resume(struct pci_dev *pdev)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5228
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5229
	struct net_device *netdev = pci_get_drvdata(pdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5230
	struct e1000_adapter *adapter = netdev_priv(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5231
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5232
	u32 err;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5233
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5234
	if (adapter->ecdev)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5235
		return -EBUSY;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5236
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5237
	pci_set_power_state(pdev, PCI_D0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5238
	pci_restore_state(pdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5239
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5240
	if (adapter->need_ioport)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5241
		err = pci_enable_device(pdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5242
	else
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5243
		err = pci_enable_device_mem(pdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5244
	if (err) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5245
		printk(KERN_ERR "e1000: Cannot enable PCI device from suspend\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5246
		return err;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5247
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5248
	pci_set_master(pdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5249
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5250
	pci_enable_wake(pdev, PCI_D3hot, 0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5251
	pci_enable_wake(pdev, PCI_D3cold, 0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5252
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5253
	if (netif_running(netdev)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5254
		err = e1000_request_irq(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5255
		if (err)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5256
			return err;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5257
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5258
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5259
	e1000_power_up_phy(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5260
	e1000_reset(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5261
	ew32(WUS, ~0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5262
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5263
	e1000_init_manageability(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5264
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5265
	if (netif_running(netdev))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5266
		e1000_up(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5267
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5268
	if (!adapter->ecdev) netif_device_attach(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5269
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5270
	/* If the controller is 82573 and f/w is AMT, do not set
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5271
	 * DRV_LOAD until the interface is up.  For all other cases,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5272
	 * let the f/w know that the h/w is now under the control
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5273
	 * of the driver. */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5274
	if (hw->mac_type != e1000_82573 ||
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5275
	    !e1000_check_mng_mode(hw))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5276
		e1000_get_hw_control(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5277
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5278
	return 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5279
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5280
#endif
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5281
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5282
static void e1000_shutdown(struct pci_dev *pdev)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5283
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5284
	e1000_suspend(pdev, PMSG_SUSPEND);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5285
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5286
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5287
#ifdef CONFIG_NET_POLL_CONTROLLER
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5288
/*
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5289
 * Polling 'interrupt' - used by things like netconsole to send skbs
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5290
 * without having to re-enable interrupts. It's not called while
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5291
 * the interrupt routine is executing.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5292
 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5293
static void e1000_netpoll(struct net_device *netdev)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5294
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5295
	struct e1000_adapter *adapter = netdev_priv(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5296
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5297
	disable_irq(adapter->pdev->irq);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5298
	e1000_intr(adapter->pdev->irq, netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5299
	enable_irq(adapter->pdev->irq);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5300
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5301
#endif
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5302
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5303
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5304
 * e1000_io_error_detected - called when PCI error is detected
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5305
 * @pdev: Pointer to PCI device
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5306
 * @state: The current pci conneection state
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5307
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5308
 * This function is called after a PCI bus error affecting
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5309
 * this device has been detected.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5310
 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5311
static pci_ers_result_t e1000_io_error_detected(struct pci_dev *pdev,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5312
						pci_channel_state_t state)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5313
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5314
	struct net_device *netdev = pci_get_drvdata(pdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5315
	struct e1000_adapter *adapter = netdev->priv;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5316
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5317
	netif_device_detach(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5318
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5319
	if (netif_running(netdev))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5320
		e1000_down(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5321
	pci_disable_device(pdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5322
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5323
	/* Request a slot slot reset. */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5324
	return PCI_ERS_RESULT_NEED_RESET;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5325
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5326
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5327
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5328
 * e1000_io_slot_reset - called after the pci bus has been reset.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5329
 * @pdev: Pointer to PCI device
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5330
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5331
 * Restart the card from scratch, as if from a cold-boot. Implementation
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5332
 * resembles the first-half of the e1000_resume routine.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5333
 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5334
static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5335
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5336
	struct net_device *netdev = pci_get_drvdata(pdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5337
	struct e1000_adapter *adapter = netdev->priv;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5338
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5339
	int err;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5340
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5341
	if (adapter->need_ioport)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5342
		err = pci_enable_device(pdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5343
	else
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5344
		err = pci_enable_device_mem(pdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5345
	if (err) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5346
		printk(KERN_ERR "e1000: Cannot re-enable PCI device after reset.\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5347
		return PCI_ERS_RESULT_DISCONNECT;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5348
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5349
	pci_set_master(pdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5350
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5351
	pci_enable_wake(pdev, PCI_D3hot, 0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5352
	pci_enable_wake(pdev, PCI_D3cold, 0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5353
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5354
	e1000_reset(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5355
	ew32(WUS, ~0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5356
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5357
	return PCI_ERS_RESULT_RECOVERED;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5358
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5359
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5360
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5361
 * e1000_io_resume - called when traffic can start flowing again.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5362
 * @pdev: Pointer to PCI device
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5363
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5364
 * This callback is called when the error recovery driver tells us that
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5365
 * its OK to resume normal operation. Implementation resembles the
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5366
 * second-half of the e1000_resume routine.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5367
 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5368
static void e1000_io_resume(struct pci_dev *pdev)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5369
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5370
	struct net_device *netdev = pci_get_drvdata(pdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5371
	struct e1000_adapter *adapter = netdev->priv;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5372
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5373
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5374
	e1000_init_manageability(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5375
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5376
	if (netif_running(netdev)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5377
		if (e1000_up(adapter)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5378
			printk("e1000: can't bring device back up after reset\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5379
			return;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5380
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5381
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5382
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5383
	netif_device_attach(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5384
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5385
	/* If the controller is 82573 and f/w is AMT, do not set
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5386
	 * DRV_LOAD until the interface is up.  For all other cases,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5387
	 * let the f/w know that the h/w is now under the control
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5388
	 * of the driver. */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5389
	if (hw->mac_type != e1000_82573 ||
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5390
	    !e1000_check_mng_mode(hw))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5391
		e1000_get_hw_control(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5392
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5393
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5394
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5395
/* e1000_main.c */