devices/e1000/e1000_main-2.6.27-ethercat.c
author Florian Pose <fp@igh-essen.com>
Thu, 15 Dec 2011 13:26:37 +0100
branchstable-1.5
changeset 2200 9f7856d9462f
parent 2050 a3e59f2a8589
child 2252 6001f50617a7
permissions -rw-r--r--
Removed executable permissions.
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;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   272
 
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;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   334
 
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) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1251
 		if (ecdev_open(adapter->ecdev)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1252
 			ecdev_withdraw(adapter->ecdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1253
 			goto err_register;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1254
 		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1255
 	} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1256
		/* 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
  1257
		netif_carrier_off(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1258
		netif_stop_queue(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1259
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1260
		strcpy(netdev->name, "eth%d");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1261
		err = register_netdev(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1262
		if (err)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1263
			goto err_register;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1264
 	}
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
	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
  1267
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1268
	cards_found++;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1269
	return 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1270
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1271
err_register:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1272
	e1000_release_hw_control(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1273
err_eeprom:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1274
	if (!e1000_check_phy_reset_block(hw))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1275
		e1000_phy_hw_reset(hw);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1276
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1277
	if (hw->flash_address)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1278
		iounmap(hw->flash_address);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1279
err_flashmap:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1280
	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
  1281
		dev_put(&adapter->polling_netdev[i]);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1282
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1283
	kfree(adapter->tx_ring);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1284
	kfree(adapter->rx_ring);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1285
	kfree(adapter->polling_netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1286
err_sw_init:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1287
	iounmap(hw->hw_addr);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1288
err_ioremap:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1289
	free_netdev(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1290
err_alloc_etherdev:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1291
	pci_release_selected_regions(pdev, bars);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1292
err_pci_reg:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1293
err_dma:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1294
	pci_disable_device(pdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1295
	return err;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1296
}
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
 * e1000_remove - Device Removal Routine
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1300
 * @pdev: PCI device information struct
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1301
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1302
 * 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
  1303
 * 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
  1304
 * 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
  1305
 * memory.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1306
 **/
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
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
  1309
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1310
	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
  1311
	struct e1000_adapter *adapter = netdev_priv(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1312
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1313
	int i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1314
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1315
	cancel_work_sync(&adapter->reset_task);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1316
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1317
	e1000_release_manageability(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1318
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1319
	/* Release control of h/w to f/w.  If f/w is AMT enabled, this
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1320
	 * 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
  1321
	e1000_release_hw_control(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1322
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1323
	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
  1324
		dev_put(&adapter->polling_netdev[i]);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1325
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1326
	if (adapter->ecdev) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1327
		ecdev_close(adapter->ecdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1328
		ecdev_withdraw(adapter->ecdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1329
	} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1330
		unregister_netdev(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1331
	}
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
	if (!e1000_check_phy_reset_block(hw))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1334
		e1000_phy_hw_reset(hw);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1335
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1336
	kfree(adapter->tx_ring);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1337
	kfree(adapter->rx_ring);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1338
	kfree(adapter->polling_netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1339
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1340
	iounmap(hw->hw_addr);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1341
	if (hw->flash_address)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1342
		iounmap(hw->flash_address);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1343
	pci_release_selected_regions(pdev, adapter->bars);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1344
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1345
	free_netdev(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1346
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1347
	pci_disable_device(pdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1348
}
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
 * 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
  1352
 * @adapter: board private structure to initialize
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1353
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1354
 * 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
  1355
 * 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
  1356
 * OS network device settings (MTU size).
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1357
 **/
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
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
  1360
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1361
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1362
	struct net_device *netdev = adapter->netdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1363
	struct pci_dev *pdev = adapter->pdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1364
	int i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1365
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1366
	/* PCI config space info */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1367
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1368
	hw->vendor_id = pdev->vendor;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1369
	hw->device_id = pdev->device;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1370
	hw->subsystem_vendor_id = pdev->subsystem_vendor;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1371
	hw->subsystem_id = pdev->subsystem_device;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1372
	hw->revision_id = pdev->revision;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1373
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1374
	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
  1375
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1376
	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
  1377
	adapter->rx_ps_bsize0 = E1000_RXBUFFER_128;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1378
	hw->max_frame_size = netdev->mtu +
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1379
			     ENET_HEADER_SIZE + ETHERNET_FCS_SIZE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1380
	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
  1381
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1382
	/* identify the MAC */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1383
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1384
	if (e1000_set_mac_type(hw)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1385
		DPRINTK(PROBE, ERR, "Unknown MAC Type\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1386
		return -EIO;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1387
	}
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
	switch (hw->mac_type) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1390
	default:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1391
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1392
	case e1000_82541:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1393
	case e1000_82547:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1394
	case e1000_82541_rev_2:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1395
	case e1000_82547_rev_2:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1396
		hw->phy_init_script = 1;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1397
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1398
	}
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
	e1000_set_media_type(hw);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1401
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1402
	hw->wait_autoneg_complete = false;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1403
	hw->tbi_compatibility_en = true;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1404
	hw->adaptive_ifs = true;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1405
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1406
	/* Copper options */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1407
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1408
	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
  1409
		hw->mdix = AUTO_ALL_MODES;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1410
		hw->disable_polarity_correction = false;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1411
		hw->master_slave = E1000_MASTER_SLAVE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1412
	}
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
	adapter->num_tx_queues = 1;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1415
	adapter->num_rx_queues = 1;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1416
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1417
	if (e1000_alloc_queues(adapter)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1418
		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
  1419
		return -ENOMEM;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1420
	}
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
	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
  1423
		adapter->polling_netdev[i].priv = adapter;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1424
		dev_hold(&adapter->polling_netdev[i]);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1425
		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
  1426
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1427
	spin_lock_init(&adapter->tx_queue_lock);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1428
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1429
	/* 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
  1430
	e1000_irq_disable(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1431
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1432
	spin_lock_init(&adapter->stats_lock);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1433
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1434
	set_bit(__E1000_DOWN, &adapter->flags);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1435
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1436
	return 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1437
}
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
 * 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
  1441
 * @adapter: board private structure to initialize
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1442
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1443
 * 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
  1444
 * 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
  1445
 * 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
  1446
 **/
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
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
  1449
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1450
	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
  1451
	                           sizeof(struct e1000_tx_ring), GFP_KERNEL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1452
	if (!adapter->tx_ring)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1453
		return -ENOMEM;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1454
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1455
	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
  1456
	                           sizeof(struct e1000_rx_ring), GFP_KERNEL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1457
	if (!adapter->rx_ring) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1458
		kfree(adapter->tx_ring);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1459
		return -ENOMEM;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1460
	}
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
	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
  1463
	                                  sizeof(struct net_device),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1464
	                                  GFP_KERNEL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1465
	if (!adapter->polling_netdev) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1466
		kfree(adapter->tx_ring);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1467
		kfree(adapter->rx_ring);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1468
		return -ENOMEM;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1469
	}
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
	return E1000_SUCCESS;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1472
}
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
 * 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
  1476
 * @netdev: network interface device structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1477
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1478
 * 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
  1479
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1480
 * 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
  1481
 * 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
  1482
 * 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
  1483
 * 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
  1484
 * 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
  1485
 **/
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
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
  1488
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1489
	struct e1000_adapter *adapter = netdev_priv(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1490
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1491
	int err;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1492
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1493
	/* disallow open during test */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1494
	if (test_bit(__E1000_TESTING, &adapter->flags))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1495
		return -EBUSY;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1496
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1497
	/* allocate transmit descriptors */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1498
	err = e1000_setup_all_tx_resources(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1499
	if (err)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1500
		goto err_setup_tx;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1501
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1502
	/* allocate receive descriptors */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1503
	err = e1000_setup_all_rx_resources(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1504
	if (err)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1505
		goto err_setup_rx;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1506
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1507
	e1000_power_up_phy(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1508
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1509
	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
  1510
	if ((hw->mng_cookie.status &
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1511
			  E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1512
		e1000_update_mng_vlan(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1513
	}
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
	/* 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
  1516
	 * interface is now open */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1517
	if (hw->mac_type == e1000_82573 &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1518
	    e1000_check_mng_mode(hw))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1519
		e1000_get_hw_control(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1520
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1521
	/* 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
  1522
	 * 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
  1523
	 * 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
  1524
	 * clean_rx handler before we do so.  */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1525
	e1000_configure(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1526
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1527
	err = e1000_request_irq(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1528
	if (err)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1529
		goto err_req_irq;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1530
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1531
	/* 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
  1532
	clear_bit(__E1000_DOWN, &adapter->flags);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1533
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1534
	napi_enable(&adapter->napi);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1535
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1536
	e1000_irq_enable(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1537
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1538
	netif_start_queue(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1539
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1540
	/* 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
  1541
	ew32(ICS, E1000_ICS_LSC);
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
	return E1000_SUCCESS;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1544
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1545
err_req_irq:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1546
	e1000_release_hw_control(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1547
	e1000_power_down_phy(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1548
	e1000_free_all_rx_resources(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1549
err_setup_rx:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1550
	e1000_free_all_tx_resources(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1551
err_setup_tx:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1552
	e1000_reset(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1553
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1554
	return err;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1555
}
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
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1558
 * e1000_close - Disables a network interface
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1559
 * @netdev: network interface device structure
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
 * 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
  1562
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1563
 * 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
  1564
 * 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
  1565
 * 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
  1566
 * 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
  1567
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1568
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1569
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
  1570
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1571
	struct e1000_adapter *adapter = netdev_priv(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1572
	struct e1000_hw *hw = &adapter->hw;
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
	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
  1575
	e1000_down(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1576
	e1000_power_down_phy(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1577
	e1000_free_irq(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1578
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1579
	e1000_free_all_tx_resources(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1580
	e1000_free_all_rx_resources(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
	/* 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
  1583
	 * 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
  1584
	if ((hw->mng_cookie.status &
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1585
			  E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1586
	     !(adapter->vlgrp &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1587
	       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
  1588
		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
  1589
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1590
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1591
	/* 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
  1592
	 * interface is now closed */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1593
	if (hw->mac_type == e1000_82573 &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1594
	    e1000_check_mng_mode(hw))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1595
		e1000_release_hw_control(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1596
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1597
	return 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1598
}
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
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1601
 * 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
  1602
 * @adapter: address of board private structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1603
 * @start: address of beginning of memory
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1604
 * @len: length of memory
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1605
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1606
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
  1607
				  unsigned long len)
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
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1610
	unsigned long begin = (unsigned long)start;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1611
	unsigned long end = begin + len;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1612
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1613
	/* 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
  1614
	 * 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
  1615
	if (hw->mac_type == e1000_82545 ||
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1616
	    hw->mac_type == e1000_82546) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1617
		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
  1618
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1619
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1620
	return 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
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1624
 * 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
  1625
 * @adapter: board private structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1626
 * @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
  1627
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1628
 * Return 0 on success, negative on failure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1629
 **/
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
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
  1632
				    struct e1000_tx_ring *txdr)
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
	struct pci_dev *pdev = adapter->pdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1635
	int size;
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
	size = sizeof(struct e1000_buffer) * txdr->count;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1638
	txdr->buffer_info = vmalloc(size);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1639
	if (!txdr->buffer_info) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1640
		DPRINTK(PROBE, ERR,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1641
		"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
  1642
		return -ENOMEM;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1643
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1644
	memset(txdr->buffer_info, 0, size);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1645
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1646
	/* round up to nearest 4K */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1647
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1648
	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
  1649
	txdr->size = ALIGN(txdr->size, 4096);
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->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
  1652
	if (!txdr->desc) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1653
setup_tx_desc_die:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1654
		vfree(txdr->buffer_info);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1655
		DPRINTK(PROBE, ERR,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1656
		"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
  1657
		return -ENOMEM;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1658
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1659
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1660
	/* 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
  1661
	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
  1662
		void *olddesc = txdr->desc;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1663
		dma_addr_t olddma = txdr->dma;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1664
		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
  1665
				     "at %p\n", txdr->size, txdr->desc);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1666
		/* Try again, without freeing the previous */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1667
		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
  1668
		/* Failed allocation, critical failure */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1669
		if (!txdr->desc) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1670
			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
  1671
			goto setup_tx_desc_die;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1672
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1673
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1674
		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
  1675
			/* give up */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1676
			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
  1677
					    txdr->dma);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1678
			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
  1679
			DPRINTK(PROBE, ERR,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1680
				"Unable to allocate aligned memory "
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1681
				"for the transmit descriptor ring\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1682
			vfree(txdr->buffer_info);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1683
			return -ENOMEM;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1684
		} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1685
			/* Free old allocation, new allocation was successful */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1686
			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
  1687
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1688
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1689
	memset(txdr->desc, 0, txdr->size);
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
	txdr->next_to_use = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1692
	txdr->next_to_clean = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1693
	spin_lock_init(&txdr->tx_lock);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1694
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1695
	return 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1696
}
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
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1699
 * 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
  1700
 * 				  (Descriptors) for all queues
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1701
 * @adapter: board private structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1702
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1703
 * Return 0 on success, negative on failure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1704
 **/
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
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
  1707
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1708
	int i, err = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1709
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1710
	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
  1711
		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
  1712
		if (err) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1713
			DPRINTK(PROBE, ERR,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1714
				"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
  1715
			for (i-- ; i >= 0; i--)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1716
				e1000_free_tx_resources(adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1717
							&adapter->tx_ring[i]);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1718
			break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1719
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1720
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1721
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1722
	return err;
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
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1726
 * 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
  1727
 * @adapter: board private structure
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
 * 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
  1730
 **/
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
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
  1733
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1734
	u64 tdba;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1735
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1736
	u32 tdlen, tctl, tipg, tarc;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1737
	u32 ipgr1, ipgr2;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1738
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1739
	/* 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
  1740
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1741
	switch (adapter->num_tx_queues) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1742
	case 1:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1743
	default:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1744
		tdba = adapter->tx_ring[0].dma;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1745
		tdlen = adapter->tx_ring[0].count *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1746
			sizeof(struct e1000_tx_desc);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1747
		ew32(TDLEN, tdlen);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1748
		ew32(TDBAH, (tdba >> 32));
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1749
		ew32(TDBAL, (tdba & 0x00000000ffffffffULL));
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1750
		ew32(TDT, 0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1751
		ew32(TDH, 0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1752
		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
  1753
		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
  1754
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1755
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1756
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1757
	/* 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
  1758
	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
  1759
	    (hw->media_type == e1000_media_type_fiber ||
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1760
	     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
  1761
		tipg = DEFAULT_82543_TIPG_IPGT_FIBER;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1762
	else
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1763
		tipg = DEFAULT_82543_TIPG_IPGT_COPPER;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1764
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1765
	switch (hw->mac_type) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1766
	case e1000_82542_rev2_0:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1767
	case e1000_82542_rev2_1:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1768
		tipg = DEFAULT_82542_TIPG_IPGT;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1769
		ipgr1 = DEFAULT_82542_TIPG_IPGR1;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1770
		ipgr2 = DEFAULT_82542_TIPG_IPGR2;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1771
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1772
	case e1000_80003es2lan:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1773
		ipgr1 = DEFAULT_82543_TIPG_IPGR1;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1774
		ipgr2 = DEFAULT_80003ES2LAN_TIPG_IPGR2;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1775
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1776
	default:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1777
		ipgr1 = DEFAULT_82543_TIPG_IPGR1;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1778
		ipgr2 = DEFAULT_82543_TIPG_IPGR2;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1779
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1780
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1781
	tipg |= ipgr1 << E1000_TIPG_IPGR1_SHIFT;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1782
	tipg |= ipgr2 << E1000_TIPG_IPGR2_SHIFT;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1783
	ew32(TIPG, tipg);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1784
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1785
	/* Set the Tx Interrupt Delay register */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1786
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1787
	ew32(TIDV, adapter->tx_int_delay);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1788
	if (hw->mac_type >= e1000_82540)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1789
		ew32(TADV, adapter->tx_abs_int_delay);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1790
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1791
	/* Program the Transmit Control Register */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1792
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1793
	tctl = er32(TCTL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1794
	tctl &= ~E1000_TCTL_CT;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1795
	tctl |= E1000_TCTL_PSP | E1000_TCTL_RTLC |
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1796
		(E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1797
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1798
	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
  1799
		tarc = er32(TARC0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1800
		/* 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
  1801
		 * gigabit link later */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1802
		tarc |= (1 << 21);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1803
		ew32(TARC0, tarc);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1804
	} else if (hw->mac_type == e1000_80003es2lan) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1805
		tarc = er32(TARC0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1806
		tarc |= 1;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1807
		ew32(TARC0, tarc);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1808
		tarc = er32(TARC1);
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(TARC1, tarc);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1811
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1812
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1813
	e1000_config_collision_dist(hw);
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
	/* Setup Transmit Descriptor Settings for eop descriptor */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1816
	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
  1817
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1818
	/* 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
  1819
	if (adapter->tx_int_delay)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1820
		adapter->txd_cmd |= E1000_TXD_CMD_IDE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1821
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1822
	if (hw->mac_type < e1000_82543)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1823
		adapter->txd_cmd |= E1000_TXD_CMD_RPS;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1824
	else
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1825
		adapter->txd_cmd |= E1000_TXD_CMD_RS;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1826
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1827
	/* 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
  1828
	 * 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
  1829
	if (hw->mac_type == e1000_82544 &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1830
	    hw->bus_type == e1000_bus_type_pcix)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1831
		adapter->pcix_82544 = 1;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1832
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1833
	ew32(TCTL, tctl);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1834
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
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
 * 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
  1839
 * @adapter: board private structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1840
 * @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
  1841
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1842
 * Returns 0 on success, negative on failure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1843
 **/
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
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
  1846
				    struct e1000_rx_ring *rxdr)
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
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1849
	struct pci_dev *pdev = adapter->pdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1850
	int size, desc_len;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1851
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1852
	size = sizeof(struct e1000_buffer) * rxdr->count;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1853
	rxdr->buffer_info = vmalloc(size);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1854
	if (!rxdr->buffer_info) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1855
		DPRINTK(PROBE, ERR,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1856
		"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
  1857
		return -ENOMEM;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1858
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1859
	memset(rxdr->buffer_info, 0, size);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1860
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1861
	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
  1862
	                        GFP_KERNEL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1863
	if (!rxdr->ps_page) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1864
		vfree(rxdr->buffer_info);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1865
		DPRINTK(PROBE, ERR,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1866
		"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
  1867
		return -ENOMEM;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1868
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1869
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1870
	rxdr->ps_page_dma = kcalloc(rxdr->count,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1871
	                            sizeof(struct e1000_ps_page_dma),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1872
	                            GFP_KERNEL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1873
	if (!rxdr->ps_page_dma) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1874
		vfree(rxdr->buffer_info);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1875
		kfree(rxdr->ps_page);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1876
		DPRINTK(PROBE, ERR,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1877
		"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
  1878
		return -ENOMEM;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1879
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1880
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1881
	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
  1882
		desc_len = sizeof(struct e1000_rx_desc);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1883
	else
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1884
		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
  1885
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1886
	/* Round up to nearest 4K */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1887
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1888
	rxdr->size = rxdr->count * desc_len;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1889
	rxdr->size = ALIGN(rxdr->size, 4096);
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->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
  1892
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1893
	if (!rxdr->desc) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1894
		DPRINTK(PROBE, ERR,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1895
		"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
  1896
setup_rx_desc_die:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1897
		vfree(rxdr->buffer_info);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1898
		kfree(rxdr->ps_page);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1899
		kfree(rxdr->ps_page_dma);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1900
		return -ENOMEM;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1901
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1902
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1903
	/* 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
  1904
	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
  1905
		void *olddesc = rxdr->desc;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1906
		dma_addr_t olddma = rxdr->dma;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1907
		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
  1908
				     "at %p\n", rxdr->size, rxdr->desc);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1909
		/* Try again, without freeing the previous */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1910
		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
  1911
		/* Failed allocation, critical failure */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1912
		if (!rxdr->desc) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1913
			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
  1914
			DPRINTK(PROBE, ERR,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1915
				"Unable to allocate memory "
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1916
				"for the receive descriptor ring\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1917
			goto setup_rx_desc_die;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1918
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1919
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1920
		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
  1921
			/* give up */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1922
			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
  1923
					    rxdr->dma);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1924
			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
  1925
			DPRINTK(PROBE, ERR,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1926
				"Unable to allocate aligned memory "
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1927
				"for the receive descriptor ring\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1928
			goto setup_rx_desc_die;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1929
		} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1930
			/* Free old allocation, new allocation was successful */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1931
			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
  1932
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1933
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1934
	memset(rxdr->desc, 0, rxdr->size);
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
	rxdr->next_to_clean = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1937
	rxdr->next_to_use = 0;
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
	return 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1940
}
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
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1943
 * 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
  1944
 * 				  (Descriptors) for all queues
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1945
 * @adapter: board private structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1946
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1947
 * Return 0 on success, negative on failure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1948
 **/
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
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
  1951
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1952
	int i, err = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1953
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1954
	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
  1955
		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
  1956
		if (err) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1957
			DPRINTK(PROBE, ERR,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1958
				"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
  1959
			for (i-- ; i >= 0; i--)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1960
				e1000_free_rx_resources(adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1961
							&adapter->rx_ring[i]);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1962
			break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1963
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1964
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1965
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1966
	return err;
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
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1970
 * 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
  1971
 * @adapter: Board private structure
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
#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
  1974
			(((S) & (PAGE_SIZE - 1)) ? 1 : 0))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1975
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
  1976
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1977
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1978
	u32 rctl, rfctl;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1979
	u32 psrctl = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1980
#ifndef CONFIG_E1000_DISABLE_PACKET_SPLIT
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1981
	u32 pages = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1982
#endif
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1983
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1984
	rctl = er32(RCTL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1985
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1986
	rctl &= ~(3 << E1000_RCTL_MO_SHIFT);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1987
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1988
	rctl |= E1000_RCTL_EN | E1000_RCTL_BAM |
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1989
		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
  1990
		(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
  1991
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1992
	if (hw->tbi_compatibility_on == 1)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1993
		rctl |= E1000_RCTL_SBP;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1994
	else
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1995
		rctl &= ~E1000_RCTL_SBP;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1996
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1997
	if (adapter->netdev->mtu <= ETH_DATA_LEN)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1998
		rctl &= ~E1000_RCTL_LPE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1999
	else
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2000
		rctl |= E1000_RCTL_LPE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2001
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2002
	/* Setup buffer sizes */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2003
	rctl &= ~E1000_RCTL_SZ_4096;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2004
	rctl |= E1000_RCTL_BSEX;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2005
	switch (adapter->rx_buffer_len) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2006
		case E1000_RXBUFFER_256:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2007
			rctl |= E1000_RCTL_SZ_256;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2008
			rctl &= ~E1000_RCTL_BSEX;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2009
			break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2010
		case E1000_RXBUFFER_512:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2011
			rctl |= E1000_RCTL_SZ_512;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2012
			rctl &= ~E1000_RCTL_BSEX;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2013
			break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2014
		case E1000_RXBUFFER_1024:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2015
			rctl |= E1000_RCTL_SZ_1024;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2016
			rctl &= ~E1000_RCTL_BSEX;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2017
			break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2018
		case E1000_RXBUFFER_2048:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2019
		default:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2020
			rctl |= E1000_RCTL_SZ_2048;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2021
			rctl &= ~E1000_RCTL_BSEX;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2022
			break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2023
		case E1000_RXBUFFER_4096:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2024
			rctl |= E1000_RCTL_SZ_4096;
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_8192:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2027
			rctl |= E1000_RCTL_SZ_8192;
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_16384:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2030
			rctl |= E1000_RCTL_SZ_16384;
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
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2033
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2034
#ifndef CONFIG_E1000_DISABLE_PACKET_SPLIT
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2035
	/* 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
  2036
	 * 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
  2037
	 * 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
  2038
	 * 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
  2039
	 * 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
  2040
	 * sized to hold the largest protocol header.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2041
	 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2042
	/* 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
  2043
	 * 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
  2044
	pages = PAGE_USE_COUNT(adapter->netdev->mtu);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2045
	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
  2046
	    PAGE_SIZE <= 16384 && (rctl & E1000_RCTL_LPE))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2047
		adapter->rx_ps_pages = pages;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2048
	else
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2049
		adapter->rx_ps_pages = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2050
#endif
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2051
	if (adapter->rx_ps_pages) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2052
		/* Configure extra packet-split registers */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2053
		rfctl = er32(RFCTL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2054
		rfctl |= E1000_RFCTL_EXTEN;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2055
		/* 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
  2056
		 * 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
  2057
		rfctl |= (E1000_RFCTL_IPV6_EX_DIS |
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2058
		          E1000_RFCTL_NEW_IPV6_EXT_DIS);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2059
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2060
		ew32(RFCTL, rfctl);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2061
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2062
		rctl |= E1000_RCTL_DTYP_PS;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2063
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2064
		psrctl |= adapter->rx_ps_bsize0 >>
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2065
			E1000_PSRCTL_BSIZE0_SHIFT;
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
		switch (adapter->rx_ps_pages) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2068
		case 3:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2069
			psrctl |= PAGE_SIZE <<
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2070
				E1000_PSRCTL_BSIZE3_SHIFT;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2071
		case 2:
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_BSIZE2_SHIFT;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2074
		case 1:
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_BSIZE1_SHIFT;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2077
			break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2078
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2079
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2080
		ew32(PSRCTL, psrctl);
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(RCTL, rctl);
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
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2087
 * 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
  2088
 * @adapter: board private structure
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
 * 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
  2091
 **/
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
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
  2094
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2095
	u64 rdba;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2096
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2097
	u32 rdlen, rctl, rxcsum, ctrl_ext;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2098
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2099
	if (adapter->rx_ps_pages) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2100
		/* this is a 32 byte descriptor */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2101
		rdlen = adapter->rx_ring[0].count *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2102
			sizeof(union e1000_rx_desc_packet_split);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2103
		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
  2104
		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
  2105
	} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2106
		rdlen = adapter->rx_ring[0].count *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2107
			sizeof(struct e1000_rx_desc);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2108
		adapter->clean_rx = e1000_clean_rx_irq;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2109
		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
  2110
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2111
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2112
	/* disable receives while setting up the descriptors */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2113
	rctl = er32(RCTL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2114
	ew32(RCTL, rctl & ~E1000_RCTL_EN);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2115
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2116
	/* set the Receive Delay Timer Register */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2117
	ew32(RDTR, adapter->rx_int_delay);
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
	if (hw->mac_type >= e1000_82540) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2120
		ew32(RADV, adapter->rx_abs_int_delay);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2121
		if (adapter->itr_setting != 0)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2122
			ew32(ITR, 1000000000 / (adapter->itr * 256));
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2123
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2124
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2125
	if (hw->mac_type >= e1000_82571) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2126
		ctrl_ext = er32(CTRL_EXT);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2127
		/* Reset delay timers after every interrupt */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2128
		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
  2129
		/* Auto-Mask interrupts upon ICR access */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2130
		ctrl_ext |= E1000_CTRL_EXT_IAME;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2131
		ew32(IAM, 0xffffffff);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2132
		ew32(CTRL_EXT, ctrl_ext);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2133
		E1000_WRITE_FLUSH();
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2134
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2135
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2136
	/* 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
  2137
	 * 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
  2138
	switch (adapter->num_rx_queues) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2139
	case 1:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2140
	default:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2141
		rdba = adapter->rx_ring[0].dma;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2142
		ew32(RDLEN, rdlen);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2143
		ew32(RDBAH, (rdba >> 32));
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2144
		ew32(RDBAL, (rdba & 0x00000000ffffffffULL));
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2145
		ew32(RDT, 0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2146
		ew32(RDH, 0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2147
		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
  2148
		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
  2149
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2150
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2151
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2152
	/* 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
  2153
	if (hw->mac_type >= e1000_82543) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2154
		rxcsum = er32(RXCSUM);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2155
		if (adapter->rx_csum) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2156
			rxcsum |= E1000_RXCSUM_TUOFL;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2157
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2158
			/* 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
  2159
			 * 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
  2160
			if ((hw->mac_type >= e1000_82571) &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2161
			    (adapter->rx_ps_pages)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2162
				rxcsum |= E1000_RXCSUM_IPPCSE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2163
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2164
		} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2165
			rxcsum &= ~E1000_RXCSUM_TUOFL;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2166
			/* 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
  2167
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2168
		ew32(RXCSUM, rxcsum);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2169
	}
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
	/* 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
  2172
	 * 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
  2173
#define E1000_ERT_2048 0x100
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2174
	if (hw->mac_type == e1000_82573)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2175
		ew32(ERT, E1000_ERT_2048);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2176
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2177
	/* Enable Receives */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2178
	ew32(RCTL, rctl);
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
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2181
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2182
 * 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
  2183
 * @adapter: board private structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2184
 * @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
  2185
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2186
 * Free all transmit software resources
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2187
 **/
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
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
  2190
				    struct e1000_tx_ring *tx_ring)
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
	struct pci_dev *pdev = adapter->pdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2193
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2194
	e1000_clean_tx_ring(adapter, tx_ring);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2195
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2196
	vfree(tx_ring->buffer_info);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2197
	tx_ring->buffer_info = NULL;
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
	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
  2200
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2201
	tx_ring->desc = NULL;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2202
}
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
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2205
 * 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
  2206
 * @adapter: board private structure
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
 * Free all transmit software resources
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2209
 **/
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
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
  2212
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2213
	int i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2214
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2215
	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
  2216
		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
  2217
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2218
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2219
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
  2220
					     struct e1000_buffer *buffer_info)
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
	if (adapter->ecdev)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2223
		return;
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 (buffer_info->dma) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2226
		pci_unmap_page(adapter->pdev,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2227
				buffer_info->dma,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2228
				buffer_info->length,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2229
				PCI_DMA_TODEVICE);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2230
		buffer_info->dma = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2231
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2232
	if (buffer_info->skb) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2233
		dev_kfree_skb_any(buffer_info->skb);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2234
		buffer_info->skb = NULL;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2235
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2236
	/* 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
  2237
}
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
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2240
 * e1000_clean_tx_ring - Free Tx Buffers
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2241
 * @adapter: board private structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2242
 * @tx_ring: ring to be cleaned
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2243
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2244
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2245
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
  2246
				struct e1000_tx_ring *tx_ring)
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
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2249
	struct e1000_buffer *buffer_info;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2250
	unsigned long size;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2251
	unsigned int i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2252
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2253
	/* Free all the Tx ring sk_buffs */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2254
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2255
	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
  2256
		buffer_info = &tx_ring->buffer_info[i];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2257
		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
  2258
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2259
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2260
	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
  2261
	memset(tx_ring->buffer_info, 0, size);
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
	/* Zero out the descriptor ring */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2264
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2265
	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
  2266
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2267
	tx_ring->next_to_use = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2268
	tx_ring->next_to_clean = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2269
	tx_ring->last_tx_tso = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2270
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2271
	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
  2272
	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
  2273
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2274
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2275
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2276
 * 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
  2277
 * @adapter: board private structure
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
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2280
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
  2281
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2282
	int i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2283
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2284
	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
  2285
		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
  2286
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2287
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2288
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2289
 * e1000_free_rx_resources - Free Rx Resources
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2290
 * @adapter: board private structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2291
 * @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
  2292
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2293
 * Free all receive software resources
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2294
 **/
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
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
  2297
				    struct e1000_rx_ring *rx_ring)
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
	struct pci_dev *pdev = adapter->pdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2300
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2301
	e1000_clean_rx_ring(adapter, rx_ring);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2302
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2303
	vfree(rx_ring->buffer_info);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2304
	rx_ring->buffer_info = NULL;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2305
	kfree(rx_ring->ps_page);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2306
	rx_ring->ps_page = NULL;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2307
	kfree(rx_ring->ps_page_dma);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2308
	rx_ring->ps_page_dma = NULL;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2309
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2310
	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
  2311
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2312
	rx_ring->desc = NULL;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2313
}
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
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2316
 * 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
  2317
 * @adapter: board private structure
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
 * Free all receive software resources
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2320
 **/
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
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
  2323
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2324
	int i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2325
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2326
	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
  2327
		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
  2328
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2329
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2330
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2331
 * 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
  2332
 * @adapter: board private structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2333
 * @rx_ring: ring to free buffers from
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2334
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2335
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2336
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
  2337
				struct e1000_rx_ring *rx_ring)
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
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2340
	struct e1000_buffer *buffer_info;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2341
	struct e1000_ps_page *ps_page;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2342
	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
  2343
	struct pci_dev *pdev = adapter->pdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2344
	unsigned long size;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2345
	unsigned int i, j;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2346
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2347
	/* Free all the Rx ring sk_buffs */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2348
	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
  2349
		buffer_info = &rx_ring->buffer_info[i];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2350
		if (buffer_info->skb) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2351
			pci_unmap_single(pdev,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2352
					 buffer_info->dma,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2353
					 buffer_info->length,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2354
					 PCI_DMA_FROMDEVICE);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2355
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2356
			dev_kfree_skb(buffer_info->skb);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2357
			buffer_info->skb = NULL;
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
		ps_page = &rx_ring->ps_page[i];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2360
		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
  2361
		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
  2362
			if (!ps_page->ps_page[j]) break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2363
			pci_unmap_page(pdev,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2364
				       ps_page_dma->ps_page_dma[j],
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2365
				       PAGE_SIZE, PCI_DMA_FROMDEVICE);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2366
			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
  2367
			put_page(ps_page->ps_page[j]);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2368
			ps_page->ps_page[j] = NULL;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2369
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2370
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2371
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2372
	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
  2373
	memset(rx_ring->buffer_info, 0, size);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2374
	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
  2375
	memset(rx_ring->ps_page, 0, size);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2376
	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
  2377
	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
  2378
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2379
	/* Zero out the descriptor ring */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2380
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2381
	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
  2382
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2383
	rx_ring->next_to_clean = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2384
	rx_ring->next_to_use = 0;
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
	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
  2387
	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
  2388
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2389
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2390
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2391
 * 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
  2392
 * @adapter: board private structure
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
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2395
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
  2396
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2397
	int i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2398
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2399
	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
  2400
		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
  2401
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2402
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2403
/* 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
  2404
 * 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
  2405
 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2406
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
  2407
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2408
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2409
	struct net_device *netdev = adapter->netdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2410
	u32 rctl;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2411
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2412
	e1000_pci_clear_mwi(hw);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2413
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2414
	rctl = er32(RCTL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2415
	rctl |= E1000_RCTL_RST;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2416
	ew32(RCTL, rctl);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2417
	E1000_WRITE_FLUSH();
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2418
	mdelay(5);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2419
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2420
	if (!adapter->ecdev && netif_running(netdev))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2421
		e1000_clean_all_rx_rings(adapter);
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
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2424
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
  2425
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2426
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2427
	struct net_device *netdev = adapter->netdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2428
	u32 rctl;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2429
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2430
	rctl = er32(RCTL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2431
	rctl &= ~E1000_RCTL_RST;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2432
	ew32(RCTL, rctl);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2433
	E1000_WRITE_FLUSH();
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2434
	mdelay(5);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2435
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2436
	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
  2437
		e1000_pci_set_mwi(hw);
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 (!adapter->netdev && netif_running(netdev)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2440
		/* 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
  2441
		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
  2442
		e1000_configure_rx(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2443
		if (adapter->ecdev) { 
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2444
			/* fill rx ring completely! */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2445
			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
  2446
		} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2447
            /* 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
  2448
			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
  2449
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2450
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2451
	}
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
 * 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
  2456
 * @netdev: network interface device structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2457
 * @p: pointer to an address structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2458
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2459
 * Returns 0 on success, negative on failure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2460
 **/
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
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
  2463
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2464
	struct e1000_adapter *adapter = netdev_priv(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2465
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2466
	struct sockaddr *addr = p;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2467
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2468
	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
  2469
		return -EADDRNOTAVAIL;
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
	/* 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
  2472
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2473
	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
  2474
		e1000_enter_82542_rst(adapter);
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
	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
  2477
	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
  2478
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2479
	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
  2480
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2481
	/* 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
  2482
	 * 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
  2483
	if (hw->mac_type == e1000_82571) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2484
		/* activate the work around */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2485
		hw->laa_is_present = 1;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2486
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2487
		/* 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
  2488
		 * 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
  2489
		 * 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
  2490
		 * 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
  2491
		 * 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
  2492
		 * RAR[14] */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2493
		e1000_rar_set(hw, hw->mac_addr,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2494
					E1000_RAR_ENTRIES - 1);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2495
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2496
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2497
	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
  2498
		e1000_leave_82542_rst(adapter);
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
	return 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2501
}
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
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2504
 * 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
  2505
 * @netdev: network interface device structure
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
 * 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
  2508
 * 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
  2509
 * 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
  2510
 * promiscuous mode, and all-multi behavior.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2511
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2512
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2513
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
  2514
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2515
	struct e1000_adapter *adapter = netdev_priv(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2516
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2517
	struct dev_addr_list *uc_ptr;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2518
	struct dev_addr_list *mc_ptr;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2519
	u32 rctl;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2520
	u32 hash_value;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2521
	int i, rar_entries = E1000_RAR_ENTRIES;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2522
	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
  2523
				E1000_NUM_MTA_REGISTERS_ICH8LAN :
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2524
				E1000_NUM_MTA_REGISTERS;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2525
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2526
	if (hw->mac_type == e1000_ich8lan)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2527
		rar_entries = E1000_RAR_ENTRIES_ICH8LAN;
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
	/* 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
  2530
	if (hw->mac_type == e1000_82571)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2531
		rar_entries--;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2532
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2533
	/* Check for Promiscuous and All Multicast modes */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2534
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2535
	rctl = er32(RCTL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2536
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2537
	if (netdev->flags & IFF_PROMISC) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2538
		rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2539
		rctl &= ~E1000_RCTL_VFE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2540
	} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2541
		if (netdev->flags & IFF_ALLMULTI) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2542
			rctl |= E1000_RCTL_MPE;
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
			rctl &= ~E1000_RCTL_MPE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2545
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2546
		if (adapter->hw.mac_type != e1000_ich8lan)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2547
			rctl |= E1000_RCTL_VFE;
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
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2550
	uc_ptr = NULL;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2551
	if (netdev->uc_count > rar_entries - 1) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2552
		rctl |= E1000_RCTL_UPE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2553
	} else if (!(netdev->flags & IFF_PROMISC)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2554
		rctl &= ~E1000_RCTL_UPE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2555
		uc_ptr = netdev->uc_list;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2556
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2557
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2558
	ew32(RCTL, rctl);
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
	/* 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
  2561
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2562
	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
  2563
		e1000_enter_82542_rst(adapter);
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
	/* 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
  2566
	 * 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
  2567
	 * when possible.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2568
	 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2569
	 * 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
  2570
	 * 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
  2571
	 * -- 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
  2572
	 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2573
	mc_ptr = netdev->mc_list;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2574
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2575
	for (i = 1; i < rar_entries; i++) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2576
		if (uc_ptr) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2577
			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
  2578
			uc_ptr = uc_ptr->next;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2579
		} else if (mc_ptr) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2580
			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
  2581
			mc_ptr = mc_ptr->next;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2582
		} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2583
			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
  2584
			E1000_WRITE_FLUSH();
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2585
			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
  2586
			E1000_WRITE_FLUSH();
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2587
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2588
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2589
	WARN_ON(uc_ptr != NULL);
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
	/* 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
  2592
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2593
	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
  2594
		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
  2595
		E1000_WRITE_FLUSH();
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2596
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2597
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2598
	/* 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
  2599
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2600
	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
  2601
		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
  2602
		e1000_mta_set(hw, hash_value);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2603
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2604
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2605
	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
  2606
		e1000_leave_82542_rst(adapter);
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
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2609
/* 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
  2610
 * the phy */
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
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
  2613
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2614
	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
  2615
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2616
	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
  2617
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2618
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2619
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2620
 * 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
  2621
 * @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
  2622
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2623
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2624
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
  2625
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2626
	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
  2627
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2628
	struct net_device *netdev = adapter->netdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2629
	u32 tctl;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2630
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2631
	if (atomic_read(&adapter->tx_fifo_stall)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2632
		if ((er32(TDT) == er32(TDH)) &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2633
		   (er32(TDFT) == er32(TDFH)) &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2634
		   (er32(TDFTS) == er32(TDFHS))) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2635
			tctl = er32(TCTL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2636
			ew32(TCTL, tctl & ~E1000_TCTL_EN);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2637
			ew32(TDFT, adapter->tx_head_addr);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2638
			ew32(TDFH, adapter->tx_head_addr);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2639
			ew32(TDFTS, adapter->tx_head_addr);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2640
			ew32(TDFHS, adapter->tx_head_addr);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2641
			ew32(TCTL, tctl);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2642
			E1000_WRITE_FLUSH();
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2643
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2644
			adapter->tx_fifo_head = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2645
			atomic_set(&adapter->tx_fifo_stall, 0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2646
			if (!adapter->ecdev) netif_wake_queue(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2647
		} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2648
			if (!adapter->ecdev)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2649
				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
  2650
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2651
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2652
}
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
 * e1000_watchdog - Timer Call-back
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2656
 * @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
  2657
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2658
static void e1000_watchdog(unsigned long data)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2659
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2660
	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
  2661
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2662
	struct net_device *netdev = adapter->netdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2663
	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
  2664
	u32 link, tctl;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2665
	s32 ret_val;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2666
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2667
	ret_val = e1000_check_for_link(hw);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2668
	if ((ret_val == E1000_ERR_PHY) &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2669
	    (hw->phy_type == e1000_phy_igp_3) &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2670
	    (er32(CTRL) & E1000_PHY_CTRL_GBE_DISABLE)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2671
		/* See e1000_kumeran_lock_loss_workaround() */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2672
		DPRINTK(LINK, INFO,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2673
			"Gigabit has been disabled, downgrading speed\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2674
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2675
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2676
	if (hw->mac_type == e1000_82573) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2677
		e1000_enable_tx_pkt_filtering(hw);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2678
		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
  2679
			e1000_update_mng_vlan(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2680
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2681
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2682
	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
  2683
	   !(er32(TXCW) & E1000_TXCW_ANE))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2684
		link = !hw->serdes_link_down;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2685
	else
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2686
		link = er32(STATUS) & E1000_STATUS_LU;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2687
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2688
	if (link) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2689
		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
  2690
				|| (!adapter->ecdev && !netif_carrier_ok(netdev))) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2691
			u32 ctrl;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2692
			bool txb2b = true;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2693
			e1000_get_speed_and_duplex(hw,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2694
			                           &adapter->link_speed,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2695
			                           &adapter->link_duplex);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2696
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2697
			ctrl = er32(CTRL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2698
			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
  2699
			        "Flow Control: %s\n",
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2700
			        adapter->link_speed,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2701
			        adapter->link_duplex == FULL_DUPLEX ?
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2702
			        "Full Duplex" : "Half Duplex",
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2703
			        ((ctrl & E1000_CTRL_TFCE) && (ctrl &
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2704
			        E1000_CTRL_RFCE)) ? "RX/TX" : ((ctrl &
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2705
			        E1000_CTRL_RFCE) ? "RX" : ((ctrl &
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2706
			        E1000_CTRL_TFCE) ? "TX" : "None" )));
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2707
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2708
			/* 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
  2709
			 * and adjust the timeout factor */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2710
			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
  2711
			adapter->tx_timeout_factor = 1;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2712
			switch (adapter->link_speed) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2713
			case SPEED_10:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2714
				txb2b = false;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2715
				netdev->tx_queue_len = 10;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2716
				adapter->tx_timeout_factor = 8;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2717
				break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2718
			case SPEED_100:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2719
				txb2b = false;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2720
				netdev->tx_queue_len = 100;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2721
				/* maybe add some timeout factor ? */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2722
				break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2723
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2724
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2725
			if ((hw->mac_type == e1000_82571 ||
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2726
			     hw->mac_type == e1000_82572) &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2727
			    !txb2b) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2728
				u32 tarc0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2729
				tarc0 = er32(TARC0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2730
				tarc0 &= ~(1 << 21);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2731
				ew32(TARC0, tarc0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2732
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2733
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2734
			/* 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
  2735
			 * some hardware issues */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2736
			if (!adapter->tso_force &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2737
			    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
  2738
				switch (adapter->link_speed) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2739
				case SPEED_10:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2740
				case SPEED_100:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2741
					DPRINTK(PROBE,INFO,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2742
				        "10/100 speed: disabling TSO\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2743
					netdev->features &= ~NETIF_F_TSO;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2744
					netdev->features &= ~NETIF_F_TSO6;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2745
					break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2746
				case SPEED_1000:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2747
					netdev->features |= NETIF_F_TSO;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2748
					netdev->features |= NETIF_F_TSO6;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2749
					break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2750
				default:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2751
					/* oops */
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
				}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2754
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2755
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2756
			/* 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
  2757
			 * after setting TARC0 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2758
			tctl = er32(TCTL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2759
			tctl |= E1000_TCTL_EN;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2760
			ew32(TCTL, tctl);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2761
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2762
			if (adapter->ecdev) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2763
				ecdev_set_link(adapter->ecdev, 1);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2764
			} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2765
				netif_carrier_on(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2766
				netif_wake_queue(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2767
				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
  2768
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2769
			adapter->smartspeed = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2770
		} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2771
			/* make sure the receive unit is started */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2772
			if (hw->rx_needs_kicking) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2773
				u32 rctl = er32(RCTL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2774
				ew32(RCTL, rctl | E1000_RCTL_EN);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2775
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2776
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2777
	} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2778
		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
  2779
				|| (!adapter->ecdev && netif_carrier_ok(netdev))) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2780
			adapter->link_speed = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2781
			adapter->link_duplex = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2782
			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
  2783
			if (adapter->ecdev) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2784
				ecdev_set_link(adapter->ecdev, 0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2785
			} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2786
				netif_carrier_off(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2787
				netif_stop_queue(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2788
				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
  2789
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2790
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2791
			/* 80003ES2LAN workaround--
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2792
			 * 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
  2793
			 * disable receives in the ISR and
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2794
			 * reset device here in the watchdog
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2795
			 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2796
			if (hw->mac_type == e1000_80003es2lan)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2797
				/* reset device */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2798
				schedule_work(&adapter->reset_task);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2799
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2800
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2801
		e1000_smartspeed(adapter);
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_update_stats(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
	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
  2807
	adapter->tpt_old = adapter->stats.tpt;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2808
	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
  2809
	adapter->colc_old = adapter->stats.colc;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2810
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2811
	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
  2812
	adapter->gorcl_old = adapter->stats.gorcl;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2813
	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
  2814
	adapter->gotcl_old = adapter->stats.gotcl;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2815
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2816
	e1000_update_adaptive(hw);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2817
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2818
	if (!adapter->ecdev && !netif_carrier_ok(netdev)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2819
		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
  2820
			/* 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
  2821
			 * 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
  2822
			 * 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
  2823
			 * (Do the reset outside of interrupt context). */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2824
			adapter->tx_timeout_count++;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2825
			schedule_work(&adapter->reset_task);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2826
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2827
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2828
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2829
	/* 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
  2830
	ew32(ICS, E1000_ICS_RXDMT0);
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
	/* 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
  2833
	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
  2834
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2835
	/* 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
  2836
	 * 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
  2837
	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
  2838
		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
  2839
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2840
	/* Reset the timer */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2841
	if (!adapter->ecdev)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2842
		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
  2843
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2844
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2845
enum latency_range {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2846
	lowest_latency = 0,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2847
	low_latency = 1,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2848
	bulk_latency = 2,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2849
	latency_invalid = 255
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2850
};
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2851
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2852
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2853
 * 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
  2854
 *      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
  2855
 *      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
  2856
 *      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
  2857
 *      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
  2858
 *      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
  2859
 *      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
  2860
 *      while increasing bulk throughput.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2861
 *      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
  2862
 *      parameter (see e1000_param.c)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2863
 * @adapter: pointer to adapter
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2864
 * @itr_setting: current adapter->itr
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2865
 * @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
  2866
 * @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
  2867
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2868
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
  2869
				     u16 itr_setting, int packets, int bytes)
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
	unsigned int retval = itr_setting;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2872
	struct e1000_hw *hw = &adapter->hw;
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
	if (unlikely(hw->mac_type < e1000_82540))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2875
		goto update_itr_done;
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 (packets == 0)
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
	switch (itr_setting) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2881
	case lowest_latency:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2882
		/* jumbo frames get bulk treatment*/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2883
		if (bytes/packets > 8000)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2884
			retval = bulk_latency;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2885
		else if ((packets < 5) && (bytes > 512))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2886
			retval = low_latency;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2887
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2888
	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
  2889
		if (bytes > 10000) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2890
			/* jumbo frames need bulk latency setting */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2891
			if (bytes/packets > 8000)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2892
				retval = bulk_latency;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2893
			else if ((packets < 10) || ((bytes/packets) > 1200))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2894
				retval = bulk_latency;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2895
			else if ((packets > 35))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2896
				retval = lowest_latency;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2897
		} else if (bytes/packets > 2000)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2898
			retval = bulk_latency;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2899
		else if (packets <= 2 && bytes < 512)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2900
			retval = lowest_latency;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2901
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2902
	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
  2903
		if (bytes > 25000) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2904
			if (packets > 35)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2905
				retval = low_latency;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2906
		} else if (bytes < 6000) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2907
			retval = low_latency;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2908
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2909
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2910
	}
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
update_itr_done:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2913
	return retval;
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
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2916
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
  2917
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2918
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2919
	u16 current_itr;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2920
	u32 new_itr = adapter->itr;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2921
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2922
	if (unlikely(hw->mac_type < e1000_82540))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2923
		return;
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
	/* 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
  2926
	if (unlikely(adapter->link_speed != SPEED_1000)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2927
		current_itr = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2928
		new_itr = 4000;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2929
		goto set_itr_now;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2930
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2931
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2932
	adapter->tx_itr = e1000_update_itr(adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2933
	                            adapter->tx_itr,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2934
	                            adapter->total_tx_packets,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2935
	                            adapter->total_tx_bytes);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2936
	/* 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
  2937
	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
  2938
		adapter->tx_itr = low_latency;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2939
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2940
	adapter->rx_itr = e1000_update_itr(adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2941
	                            adapter->rx_itr,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2942
	                            adapter->total_rx_packets,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2943
	                            adapter->total_rx_bytes);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2944
	/* 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
  2945
	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
  2946
		adapter->rx_itr = low_latency;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2947
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2948
	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
  2949
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2950
	switch (current_itr) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2951
	/* 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
  2952
	case lowest_latency:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2953
		new_itr = 70000;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2954
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2955
	case low_latency:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2956
		new_itr = 20000; /* aka hwitr = ~200 */
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 bulk_latency:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2959
		new_itr = 4000;
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
	default:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2962
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2963
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2964
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2965
set_itr_now:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2966
	if (new_itr != adapter->itr) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2967
		/* 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
  2968
		 * 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
  2969
		 * increasing */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2970
		new_itr = new_itr > adapter->itr ?
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2971
		             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
  2972
		             new_itr;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2973
		adapter->itr = new_itr;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2974
		ew32(ITR, 1000000000 / (new_itr * 256));
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2975
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2976
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2977
	return;
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
#define E1000_TX_FLAGS_CSUM		0x00000001
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2981
#define E1000_TX_FLAGS_VLAN		0x00000002
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2982
#define E1000_TX_FLAGS_TSO		0x00000004
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2983
#define E1000_TX_FLAGS_IPV4		0x00000008
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2984
#define E1000_TX_FLAGS_VLAN_MASK	0xffff0000
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2985
#define E1000_TX_FLAGS_VLAN_SHIFT	16
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2986
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2987
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
  2988
		     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
  2989
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2990
	struct e1000_context_desc *context_desc;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2991
	struct e1000_buffer *buffer_info;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2992
	unsigned int i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2993
	u32 cmd_length = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2994
	u16 ipcse = 0, tucse, mss;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2995
	u8 ipcss, ipcso, tucss, tucso, hdr_len;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2996
	int err;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2997
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2998
	if (skb_is_gso(skb)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2999
		if (skb_header_cloned(skb)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3000
			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
  3001
			if (err)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3002
				return err;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3003
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3004
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3005
		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
  3006
		mss = skb_shinfo(skb)->gso_size;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3007
		if (skb->protocol == htons(ETH_P_IP)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3008
			struct iphdr *iph = ip_hdr(skb);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3009
			iph->tot_len = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3010
			iph->check = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3011
			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
  3012
								 iph->daddr, 0,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3013
								 IPPROTO_TCP,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3014
								 0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3015
			cmd_length = E1000_TXD_CMD_IP;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3016
			ipcse = skb_transport_offset(skb) - 1;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3017
		} 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
  3018
			ipv6_hdr(skb)->payload_len = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3019
			tcp_hdr(skb)->check =
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3020
				~csum_ipv6_magic(&ipv6_hdr(skb)->saddr,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3021
						 &ipv6_hdr(skb)->daddr,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3022
						 0, IPPROTO_TCP, 0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3023
			ipcse = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3024
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3025
		ipcss = skb_network_offset(skb);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3026
		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
  3027
		tucss = skb_transport_offset(skb);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3028
		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
  3029
		tucse = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3030
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3031
		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
  3032
			       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
  3033
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3034
		i = tx_ring->next_to_use;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3035
		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
  3036
		buffer_info = &tx_ring->buffer_info[i];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3037
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3038
		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
  3039
		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
  3040
		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
  3041
		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
  3042
		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
  3043
		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
  3044
		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
  3045
		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
  3046
		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
  3047
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3048
		buffer_info->time_stamp = jiffies;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3049
		buffer_info->next_to_watch = i;
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
		if (++i == tx_ring->count) i = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3052
		tx_ring->next_to_use = 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
		return true;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3055
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3056
	return false;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3057
}
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
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
  3060
			  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
  3061
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3062
	struct e1000_context_desc *context_desc;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3063
	struct e1000_buffer *buffer_info;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3064
	unsigned int i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3065
	u8 css;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3066
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3067
	if (likely(skb->ip_summed == CHECKSUM_PARTIAL)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3068
		css = skb_transport_offset(skb);
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
		i = tx_ring->next_to_use;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3071
		buffer_info = &tx_ring->buffer_info[i];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3072
		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
  3073
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3074
		context_desc->lower_setup.ip_config = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3075
		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
  3076
		context_desc->upper_setup.tcp_fields.tucso =
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3077
			css + skb->csum_offset;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3078
		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
  3079
		context_desc->tcp_seg_setup.data = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3080
		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
  3081
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3082
		buffer_info->time_stamp = jiffies;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3083
		buffer_info->next_to_watch = i;
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
		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
  3086
		tx_ring->next_to_use = 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
		return true;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3089
	}
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 false;
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
#define E1000_MAX_TXD_PWR	12
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3095
#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
  3096
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3097
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
  3098
			struct e1000_tx_ring *tx_ring,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3099
			struct sk_buff *skb, unsigned int first,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3100
			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
  3101
			unsigned int mss)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3102
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3103
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3104
	struct e1000_buffer *buffer_info;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3105
	unsigned int len = skb->len;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3106
	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
  3107
	unsigned int f;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3108
	len -= skb->data_len;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3109
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3110
	i = tx_ring->next_to_use;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3111
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3112
	while (len) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3113
		buffer_info = &tx_ring->buffer_info[i];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3114
		size = min(len, max_per_txd);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3115
		/* Workaround for Controller erratum --
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3116
		 * 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
  3117
		 * 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
  3118
		 * DMA'd to the controller */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3119
		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
  3120
		    !skb_is_gso(skb)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3121
			tx_ring->last_tx_tso = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3122
			size -= 4;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3123
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3124
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3125
		/* Workaround for premature desc write-backs
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3126
		 * 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
  3127
		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
  3128
			size -= 4;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3129
		/* 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
  3130
		 * to all controllers in PCI-X mode
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3131
		 * 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
  3132
		 * 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
  3133
		 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3134
		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
  3135
		                (size > 2015) && count == 0))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3136
		        size = 2015;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3137
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3138
		/* 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
  3139
		 * terminating buffers within evenly-aligned dwords. */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3140
		if (unlikely(adapter->pcix_82544 &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3141
		   !((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
  3142
		   size > 4))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3143
			size -= 4;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3144
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3145
		buffer_info->length = size;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3146
		buffer_info->dma =
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3147
			pci_map_single(adapter->pdev,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3148
				skb->data + offset,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3149
				size,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3150
				PCI_DMA_TODEVICE);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3151
		buffer_info->time_stamp = jiffies;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3152
		buffer_info->next_to_watch = i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3153
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3154
		len -= size;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3155
		offset += size;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3156
		count++;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3157
		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
  3158
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3159
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3160
	for (f = 0; f < nr_frags; f++) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3161
		struct skb_frag_struct *frag;
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
		frag = &skb_shinfo(skb)->frags[f];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3164
		len = frag->size;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3165
		offset = frag->page_offset;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3166
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3167
		while (len) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3168
			buffer_info = &tx_ring->buffer_info[i];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3169
			size = min(len, max_per_txd);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3170
			/* Workaround for premature desc write-backs
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3171
			 * 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
  3172
			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
  3173
				size -= 4;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3174
			/* 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
  3175
			 * Avoid terminating buffers within evenly-aligned
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3176
			 * dwords. */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3177
			if (unlikely(adapter->pcix_82544 &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3178
			   !((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
  3179
			   size > 4))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3180
				size -= 4;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3181
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3182
			buffer_info->length = size;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3183
			buffer_info->dma =
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3184
				pci_map_page(adapter->pdev,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3185
					frag->page,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3186
					offset,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3187
					size,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3188
					PCI_DMA_TODEVICE);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3189
			buffer_info->time_stamp = jiffies;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3190
			buffer_info->next_to_watch = i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3191
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3192
			len -= size;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3193
			offset += size;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3194
			count++;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3195
			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
  3196
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3197
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3198
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3199
	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
  3200
	tx_ring->buffer_info[i].skb = skb;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3201
	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
  3202
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3203
	return count;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3204
}
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
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
  3207
			   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
  3208
			   int count)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3209
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3210
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3211
	struct e1000_tx_desc *tx_desc = NULL;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3212
	struct e1000_buffer *buffer_info;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3213
	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
  3214
	unsigned int i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3215
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3216
	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
  3217
		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
  3218
		             E1000_TXD_CMD_TSE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3219
		txd_upper |= E1000_TXD_POPTS_TXSM << 8;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3220
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3221
		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
  3222
			txd_upper |= E1000_TXD_POPTS_IXSM << 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
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3225
	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
  3226
		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
  3227
		txd_upper |= E1000_TXD_POPTS_TXSM << 8;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3228
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3229
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3230
	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
  3231
		txd_lower |= E1000_TXD_CMD_VLE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3232
		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
  3233
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3234
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3235
	i = tx_ring->next_to_use;
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
	while (count--) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3238
		buffer_info = &tx_ring->buffer_info[i];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3239
		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
  3240
		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
  3241
		tx_desc->lower.data =
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3242
			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
  3243
		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
  3244
		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
  3245
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3246
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3247
	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
  3248
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3249
	/* 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
  3250
	 * 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
  3251
	 * applicable for weak-ordered memory model archs,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3252
	 * such as IA-64). */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3253
	wmb();
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3254
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3255
	tx_ring->next_to_use = i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3256
	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
  3257
	/* 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
  3258
	 * 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
  3259
	mmiowb();
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3260
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3261
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3262
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3263
 * 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
  3264
 * 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
  3265
 * 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
  3266
 * 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
  3267
 * 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
  3268
 * to the beginning of the Tx FIFO.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3269
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3270
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3271
#define E1000_FIFO_HDR			0x10
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3272
#define E1000_82547_PAD_LEN		0x3E0
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
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
  3275
				       struct sk_buff *skb)
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
	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
  3278
	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
  3279
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3280
	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
  3281
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3282
	if (adapter->link_duplex != HALF_DUPLEX)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3283
		goto no_fifo_stall_required;
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 (atomic_read(&adapter->tx_fifo_stall))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3286
		return 1;
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 (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
  3289
		atomic_set(&adapter->tx_fifo_stall, 1);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3290
		return 1;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3291
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3292
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3293
no_fifo_stall_required:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3294
	adapter->tx_fifo_head += skb_fifo_len;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3295
	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
  3296
		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
  3297
	return 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3298
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3299
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3300
#define MINIMUM_DHCP_PACKET_SIZE 282
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3301
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
  3302
				    struct sk_buff *skb)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3303
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3304
	struct e1000_hw *hw =  &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3305
	u16 length, offset;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3306
	if (vlan_tx_tag_present(skb)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3307
		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
  3308
			( hw->mng_cookie.status &
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3309
			  E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) )
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3310
			return 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3311
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3312
	if (skb->len > MINIMUM_DHCP_PACKET_SIZE) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3313
		struct ethhdr *eth = (struct ethhdr *)skb->data;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3314
		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
  3315
			const struct iphdr *ip =
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3316
				(struct iphdr *)((u8 *)skb->data+14);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3317
			if (IPPROTO_UDP == ip->protocol) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3318
				struct udphdr *udp =
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3319
					(struct udphdr *)((u8 *)ip +
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3320
						(ip->ihl << 2));
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3321
				if (ntohs(udp->dest) == 67) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3322
					offset = (u8 *)udp + 8 - skb->data;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3323
					length = skb->len - offset;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3324
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3325
					return e1000_mng_write_dhcp_info(hw,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3326
							(u8 *)udp + 8,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3327
							length);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3328
				}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3329
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3330
		}
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
	return 0;
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
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
  3336
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3337
	struct e1000_adapter *adapter = netdev_priv(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3338
	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
  3339
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3340
	netif_stop_queue(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3341
	/* Herbert's original patch had:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3342
	 *  smp_mb__after_netif_stop_queue();
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3343
	 * 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
  3344
	smp_mb();
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3345
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3346
	/* 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
  3347
	 * made room available. */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3348
	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
  3349
		return -EBUSY;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3350
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3351
	/* A reprieve! */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3352
	netif_start_queue(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3353
	++adapter->restart_queue;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3354
	return 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3355
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3356
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3357
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
  3358
                               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
  3359
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3360
	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
  3361
		return 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3362
	return __e1000_maybe_stop_tx(netdev, size);
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
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3365
#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
  3366
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
  3367
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3368
	struct e1000_adapter *adapter = netdev_priv(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3369
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3370
	struct e1000_tx_ring *tx_ring;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3371
	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
  3372
	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
  3373
	unsigned int tx_flags = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3374
	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
  3375
	unsigned long flags = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3376
	unsigned int nr_frags = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3377
	unsigned int mss = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3378
	int count = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3379
	int tso;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3380
	unsigned int f;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3381
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3382
	/* 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
  3383
	 * 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
  3384
	 * 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
  3385
	 * 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
  3386
	tx_ring = adapter->tx_ring;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3387
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3388
	if (unlikely(skb->len <= 0)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3389
		if (!adapter->ecdev)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3390
			dev_kfree_skb_any(skb);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3391
		return NETDEV_TX_OK;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3392
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3393
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3394
	/* 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
  3395
	 * length to 4kB */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3396
	if (hw->mac_type >= e1000_82571)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3397
		max_per_txd = 8192;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3398
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3399
	mss = skb_shinfo(skb)->gso_size;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3400
	/* The controller does a simple calculation to
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3401
	 * 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
  3402
	 * 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
  3403
	 * 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
  3404
	 * 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
  3405
	 * drops. */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3406
	if (mss) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3407
		u8 hdr_len;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3408
		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
  3409
		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
  3410
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3411
		/* 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
  3412
		* 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
  3413
		* frags into skb->data */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3414
		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
  3415
		if (skb->data_len && hdr_len == len) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3416
			switch (hw->mac_type) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3417
				unsigned int pull_size;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3418
			case e1000_82544:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3419
				/* 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
  3420
				 * 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
  3421
				 * this hardware's requirements
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3422
				 * NOTE: this is a TSO only workaround
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3423
				 * 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
  3424
				 * into the next dword */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3425
				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
  3426
					break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3427
				/* fall through */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3428
			case e1000_82571:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3429
			case e1000_82572:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3430
			case e1000_82573:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3431
			case e1000_ich8lan:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3432
				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
  3433
				if (!__pskb_pull_tail(skb, pull_size)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3434
					DPRINTK(DRV, ERR,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3435
						"__pskb_pull_tail failed.\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3436
					dev_kfree_skb_any(skb);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3437
					return NETDEV_TX_OK;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3438
				}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3439
				len = skb->len - skb->data_len;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3440
				break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3441
			default:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3442
				/* do nothing */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3443
				break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3444
			}
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
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3447
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3448
	/* reserve a descriptor for the offload context */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3449
	if ((mss) || (skb->ip_summed == CHECKSUM_PARTIAL))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3450
		count++;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3451
	count++;
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
	/* Controller Erratum workaround */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3454
	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
  3455
		count++;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3456
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3457
	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
  3458
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3459
	if (adapter->pcix_82544)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3460
		count++;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3461
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3462
	/* 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
  3463
	 * 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
  3464
	 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3465
	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
  3466
			(len > 2015)))
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
	nr_frags = skb_shinfo(skb)->nr_frags;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3470
	for (f = 0; f < nr_frags; f++)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3471
		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
  3472
				       max_txd_pwr);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3473
	if (adapter->pcix_82544)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3474
		count += nr_frags;
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
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3477
	if (hw->tx_pkt_filtering &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3478
	    (hw->mac_type == e1000_82573))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3479
		e1000_transfer_dhcp_info(adapter, skb);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3480
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3481
 	if (!adapter->ecdev &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3482
 			!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
  3483
		/* Collision - tell upper layer to requeue */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3484
		return NETDEV_TX_LOCKED;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3485
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3486
	/* 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
  3487
	 * head, otherwise try next time */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3488
	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
  3489
		if (!adapter->ecdev) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3490
			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
  3491
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3492
		return NETDEV_TX_BUSY;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3493
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3494
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3495
	if (unlikely(hw->mac_type == e1000_82547)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3496
		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
  3497
			if (!adapter->ecdev) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3498
				netif_stop_queue(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3499
				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
  3500
				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
  3501
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3502
			return NETDEV_TX_BUSY;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3503
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3504
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3505
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3506
	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
  3507
		tx_flags |= E1000_TX_FLAGS_VLAN;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3508
		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
  3509
	}
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
	first = tx_ring->next_to_use;
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
	tso = e1000_tso(adapter, tx_ring, skb);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3514
	if (tso < 0) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3515
		if (!adapter->ecdev) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3516
			dev_kfree_skb_any(skb);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3517
			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
  3518
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3519
		return NETDEV_TX_OK;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3520
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3521
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3522
	if (likely(tso)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3523
		tx_ring->last_tx_tso = 1;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3524
		tx_flags |= E1000_TX_FLAGS_TSO;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3525
	} 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
  3526
		tx_flags |= E1000_TX_FLAGS_CSUM;
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
	/* 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
  3529
	 * 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
  3530
	 * no longer assume, we must. */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3531
	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
  3532
		tx_flags |= E1000_TX_FLAGS_IPV4;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3533
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3534
	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
  3535
	               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
  3536
	                            max_per_txd, nr_frags, mss));
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3537
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3538
	netdev->trans_start = jiffies;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3539
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3540
	if (!adapter->ecdev) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3541
		/* 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
  3542
		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
  3543
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3544
		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
  3545
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3546
	return NETDEV_TX_OK;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3547
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3548
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3549
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3550
 * 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
  3551
 * @netdev: network interface device structure
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
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3554
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
  3555
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3556
	struct e1000_adapter *adapter = netdev_priv(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3557
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3558
	/* Do the reset outside of interrupt context */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3559
	adapter->tx_timeout_count++;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3560
	schedule_work(&adapter->reset_task);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3561
}
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
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
  3564
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3565
	struct e1000_adapter *adapter =
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3566
		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
  3567
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3568
	e1000_reinit_locked(adapter);
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
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
 * e1000_get_stats - Get System Network Statistics
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3573
 * @netdev: network interface device structure
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
 * 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
  3576
 * 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
  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
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
  3580
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3581
	struct e1000_adapter *adapter = netdev_priv(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3582
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3583
	/* only return the current stats */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3584
	return &adapter->net_stats;
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
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
 * 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
  3589
 * @netdev: network interface device structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3590
 * @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
  3591
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3592
 * Returns 0 on success, negative on failure
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
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
  3596
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3597
	struct e1000_adapter *adapter = netdev_priv(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3598
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3599
	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
  3600
	u16 eeprom_data = 0;
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
	if (adapter->ecdev)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3603
		return -EBUSY;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3604
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3605
	if ((max_frame < MINIMUM_ETHERNET_FRAME_SIZE) ||
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3606
	    (max_frame > MAX_JUMBO_FRAME_SIZE)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3607
		DPRINTK(PROBE, ERR, "Invalid MTU setting\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3608
		return -EINVAL;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3609
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3610
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3611
	/* Adapter-specific max frame size limits. */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3612
	switch (hw->mac_type) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3613
	case e1000_undefined ... e1000_82542_rev2_1:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3614
	case e1000_ich8lan:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3615
		if (max_frame > MAXIMUM_ETHERNET_FRAME_SIZE) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3616
			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
  3617
			return -EINVAL;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3618
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3619
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3620
	case e1000_82573:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3621
		/* Jumbo Frames not supported if:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3622
		 * - this is not an 82573L device
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3623
		 * - 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
  3624
		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
  3625
		                  &eeprom_data);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3626
		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
  3627
		    (eeprom_data & EEPROM_WORD1A_ASPM_MASK)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3628
			if (max_frame > MAXIMUM_ETHERNET_FRAME_SIZE) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3629
				DPRINTK(PROBE, ERR,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3630
			            	"Jumbo Frames not supported.\n");
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3631
				return -EINVAL;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3632
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3633
			break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3634
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3635
		/* 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
  3636
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3637
		/* fall through to get support */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3638
	case e1000_82571:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3639
	case e1000_82572:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3640
	case e1000_80003es2lan:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3641
#define MAX_STD_JUMBO_FRAME_SIZE 9234
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3642
		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
  3643
			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
  3644
			return -EINVAL;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3645
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3646
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3647
	default:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3648
		/* 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
  3649
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3650
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3651
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3652
	/* 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
  3653
	 * 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
  3654
	 * larger slab size
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3655
	 * i.e. RXBUFFER_2048 --> size-4096 slab */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3656
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3657
	if (max_frame <= E1000_RXBUFFER_256)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3658
		adapter->rx_buffer_len = E1000_RXBUFFER_256;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3659
	else if (max_frame <= E1000_RXBUFFER_512)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3660
		adapter->rx_buffer_len = E1000_RXBUFFER_512;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3661
	else if (max_frame <= E1000_RXBUFFER_1024)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3662
		adapter->rx_buffer_len = E1000_RXBUFFER_1024;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3663
	else if (max_frame <= E1000_RXBUFFER_2048)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3664
		adapter->rx_buffer_len = E1000_RXBUFFER_2048;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3665
	else if (max_frame <= E1000_RXBUFFER_4096)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3666
		adapter->rx_buffer_len = E1000_RXBUFFER_4096;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3667
	else if (max_frame <= E1000_RXBUFFER_8192)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3668
		adapter->rx_buffer_len = E1000_RXBUFFER_8192;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3669
	else if (max_frame <= E1000_RXBUFFER_16384)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3670
		adapter->rx_buffer_len = E1000_RXBUFFER_16384;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3671
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3672
	/* 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
  3673
	if (!hw->tbi_compatibility_on &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3674
	    ((max_frame == MAXIMUM_ETHERNET_FRAME_SIZE) ||
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3675
	     (max_frame == MAXIMUM_ETHERNET_VLAN_SIZE)))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3676
		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
  3677
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3678
	netdev->mtu = new_mtu;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3679
	hw->max_frame_size = max_frame;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3680
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3681
	if (netif_running(netdev))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3682
		e1000_reinit_locked(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3683
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3684
	return 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3685
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3686
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
 * 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
  3689
 * @adapter: board private structure
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
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3692
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
  3693
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3694
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3695
	struct pci_dev *pdev = adapter->pdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3696
	unsigned long flags = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3697
	u16 phy_tmp;
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
#define PHY_IDLE_ERROR_COUNT_MASK 0x00FF
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
	/*
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3702
	 * 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
  3703
	 * connection is down.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3704
	 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3705
	if (adapter->link_speed == 0)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3706
		return;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3707
	if (pci_channel_offline(pdev))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3708
		return;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3709
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3710
	if (!adapter->ecdev)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3711
		spin_lock_irqsave(&adapter->stats_lock, flags);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3712
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3713
	/* 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
  3714
	 * 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
  3715
	 * be written while holding adapter->stats_lock
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
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3718
	adapter->stats.crcerrs += er32(CRCERRS);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3719
	adapter->stats.gprc += er32(GPRC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3720
	adapter->stats.gorcl += er32(GORCL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3721
	adapter->stats.gorch += er32(GORCH);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3722
	adapter->stats.bprc += er32(BPRC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3723
	adapter->stats.mprc += er32(MPRC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3724
	adapter->stats.roc += er32(ROC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3725
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3726
	if (hw->mac_type != e1000_ich8lan) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3727
		adapter->stats.prc64 += er32(PRC64);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3728
		adapter->stats.prc127 += er32(PRC127);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3729
		adapter->stats.prc255 += er32(PRC255);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3730
		adapter->stats.prc511 += er32(PRC511);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3731
		adapter->stats.prc1023 += er32(PRC1023);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3732
		adapter->stats.prc1522 += er32(PRC1522);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3733
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3734
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3735
	adapter->stats.symerrs += er32(SYMERRS);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3736
	adapter->stats.mpc += er32(MPC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3737
	adapter->stats.scc += er32(SCC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3738
	adapter->stats.ecol += er32(ECOL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3739
	adapter->stats.mcc += er32(MCC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3740
	adapter->stats.latecol += er32(LATECOL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3741
	adapter->stats.dc += er32(DC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3742
	adapter->stats.sec += er32(SEC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3743
	adapter->stats.rlec += er32(RLEC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3744
	adapter->stats.xonrxc += er32(XONRXC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3745
	adapter->stats.xontxc += er32(XONTXC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3746
	adapter->stats.xoffrxc += er32(XOFFRXC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3747
	adapter->stats.xofftxc += er32(XOFFTXC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3748
	adapter->stats.fcruc += er32(FCRUC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3749
	adapter->stats.gptc += er32(GPTC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3750
	adapter->stats.gotcl += er32(GOTCL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3751
	adapter->stats.gotch += er32(GOTCH);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3752
	adapter->stats.rnbc += er32(RNBC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3753
	adapter->stats.ruc += er32(RUC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3754
	adapter->stats.rfc += er32(RFC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3755
	adapter->stats.rjc += er32(RJC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3756
	adapter->stats.torl += er32(TORL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3757
	adapter->stats.torh += er32(TORH);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3758
	adapter->stats.totl += er32(TOTL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3759
	adapter->stats.toth += er32(TOTH);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3760
	adapter->stats.tpr += er32(TPR);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3761
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3762
	if (hw->mac_type != e1000_ich8lan) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3763
		adapter->stats.ptc64 += er32(PTC64);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3764
		adapter->stats.ptc127 += er32(PTC127);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3765
		adapter->stats.ptc255 += er32(PTC255);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3766
		adapter->stats.ptc511 += er32(PTC511);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3767
		adapter->stats.ptc1023 += er32(PTC1023);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3768
		adapter->stats.ptc1522 += er32(PTC1522);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3769
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3770
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3771
	adapter->stats.mptc += er32(MPTC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3772
	adapter->stats.bptc += er32(BPTC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3773
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3774
	/* used for adaptive IFS */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3775
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3776
	hw->tx_packet_delta = er32(TPT);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3777
	adapter->stats.tpt += hw->tx_packet_delta;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3778
	hw->collision_delta = er32(COLC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3779
	adapter->stats.colc += hw->collision_delta;
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
	if (hw->mac_type >= e1000_82543) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3782
		adapter->stats.algnerrc += er32(ALGNERRC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3783
		adapter->stats.rxerrc += er32(RXERRC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3784
		adapter->stats.tncrs += er32(TNCRS);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3785
		adapter->stats.cexterr += er32(CEXTERR);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3786
		adapter->stats.tsctc += er32(TSCTC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3787
		adapter->stats.tsctfc += er32(TSCTFC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3788
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3789
	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
  3790
		adapter->stats.iac += er32(IAC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3791
		adapter->stats.icrxoc += er32(ICRXOC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3792
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3793
		if (hw->mac_type != e1000_ich8lan) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3794
			adapter->stats.icrxptc += er32(ICRXPTC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3795
			adapter->stats.icrxatc += er32(ICRXATC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3796
			adapter->stats.ictxptc += er32(ICTXPTC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3797
			adapter->stats.ictxatc += er32(ICTXATC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3798
			adapter->stats.ictxqec += er32(ICTXQEC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3799
			adapter->stats.ictxqmtc += er32(ICTXQMTC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3800
			adapter->stats.icrxdmtc += er32(ICRXDMTC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3801
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3802
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3803
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3804
	/* Fill out the OS statistics structure */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3805
	adapter->net_stats.multicast = adapter->stats.mprc;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3806
	adapter->net_stats.collisions = adapter->stats.colc;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3807
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3808
	/* Rx Errors */
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
	/* 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
  3811
	* 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
  3812
	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
  3813
		adapter->stats.crcerrs + adapter->stats.algnerrc +
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3814
		adapter->stats.ruc + adapter->stats.roc +
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3815
		adapter->stats.cexterr;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3816
	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
  3817
	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
  3818
	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
  3819
	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
  3820
	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
  3821
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3822
	/* Tx Errors */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3823
	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
  3824
	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
  3825
	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
  3826
	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
  3827
	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
  3828
	if (hw->bad_tx_carr_stats_fd &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3829
	    adapter->link_duplex == FULL_DUPLEX) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3830
		adapter->net_stats.tx_carrier_errors = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3831
		adapter->stats.tncrs = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3832
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3833
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3834
	/* Tx Dropped needs to be maintained elsewhere */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3835
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3836
	/* Phy Stats */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3837
	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
  3838
		if ((adapter->link_speed == SPEED_1000) &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3839
		   (!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
  3840
			phy_tmp &= PHY_IDLE_ERROR_COUNT_MASK;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3841
			adapter->phy_stats.idle_errors += phy_tmp;
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
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3844
		if ((hw->mac_type <= e1000_82546) &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3845
		   (hw->phy_type == e1000_phy_m88) &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3846
		   !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
  3847
			adapter->phy_stats.receive_errors += phy_tmp;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3848
	}
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
	/* Management Stats */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3851
	if (hw->has_smbus) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3852
		adapter->stats.mgptc += er32(MGTPTC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3853
		adapter->stats.mgprc += er32(MGTPRC);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3854
		adapter->stats.mgpdc += er32(MGTPDC);
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
	if (!adapter->ecdev)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3858
		spin_unlock_irqrestore(&adapter->stats_lock, flags);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3859
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3860
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3861
void ec_poll(struct net_device *netdev)
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
    struct e1000_adapter *adapter = netdev_priv(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3864
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3865
    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
  3866
        e1000_watchdog((unsigned long) adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3867
        adapter->ec_watchdog_jiffies = jiffies;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3868
    }
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
#ifdef CONFIG_PCI_MSI
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3871
	e1000_intr_msi(0, netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3872
#else
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3873
    e1000_intr(0, netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3874
#endif
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
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3878
 * e1000_intr_msi - Interrupt Handler
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3879
 * @irq: interrupt number
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3880
 * @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
  3881
 **/
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
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
  3884
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3885
	struct net_device *netdev = data;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3886
	struct e1000_adapter *adapter = netdev_priv(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3887
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3888
	u32 icr = er32(ICR);
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
 	if (adapter->ecdev) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3891
 		int i, ec_work_done = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3892
 		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
  3893
 			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
  3894
                             &ec_work_done, 100) &&
1900
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3895
 						!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
  3896
 				break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3897
 			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3898
 		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3899
 	} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3900
		/* 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
  3901
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3902
		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
  3903
			hw->get_link_status = 1;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3904
			/* 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
  3905
			 * 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
  3906
			 * adapter in watchdog */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3907
			if (netif_carrier_ok(netdev) &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3908
				(hw->mac_type == e1000_80003es2lan)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3909
				/* disable receives */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3910
				u32 rctl = er32(RCTL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3911
				ew32(RCTL, rctl & ~E1000_RCTL_EN);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3912
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3913
			/* 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
  3914
			if (!test_bit(__E1000_DOWN, &adapter->flags))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3915
				mod_timer(&adapter->watchdog_timer, jiffies + 1);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3916
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3917
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3918
		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
  3919
			adapter->total_tx_bytes = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3920
			adapter->total_tx_packets = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3921
			adapter->total_rx_bytes = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3922
			adapter->total_rx_packets = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3923
			__netif_rx_schedule(netdev, &adapter->napi);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3924
		} else
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3925
			e1000_irq_enable(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3926
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3927
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3928
	return IRQ_HANDLED;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3929
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3930
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3931
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3932
 * e1000_intr - Interrupt Handler
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3933
 * @irq: interrupt number
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3934
 * @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
  3935
 **/
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
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
  3938
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3939
	struct net_device *netdev = data;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3940
	struct e1000_adapter *adapter = netdev_priv(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3941
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3942
	u32 rctl, icr = er32(ICR);
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
	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
  3945
		return IRQ_NONE;  /* Not our interrupt */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3946
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3947
	/* 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
  3948
	 * 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
  3949
	if (unlikely(hw->mac_type >= e1000_82571 &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3950
	             !(icr & E1000_ICR_INT_ASSERTED)))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3951
		return IRQ_NONE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3952
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3953
	/* 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
  3954
	 * need for the IMC write */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3955
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3956
	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
  3957
		hw->get_link_status = 1;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3958
		/* 80003ES2LAN workaround--
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3959
		 * 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
  3960
		 * disable receives here in the ISR and
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3961
		 * reset adapter in watchdog
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 (netif_carrier_ok(netdev) &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3964
		    (hw->mac_type == e1000_80003es2lan)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3965
			/* disable receives */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3966
			rctl = er32(RCTL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3967
			ew32(RCTL, rctl & ~E1000_RCTL_EN);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3968
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3969
		/* 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
  3970
		if (!test_bit(__E1000_DOWN, &adapter->flags))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3971
			mod_timer(&adapter->watchdog_timer, jiffies + 1);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3972
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3973
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3974
	if (adapter->ecdev) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3975
		int i, ec_work_done = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3976
		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
  3977
			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
  3978
							 &ec_work_done, 100) &&
1900
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3979
						!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
  3980
				break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3981
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3982
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3983
	} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3984
		if (unlikely(hw->mac_type < e1000_82571)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3985
			/* disable interrupts, without the synchronize_irq bit */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3986
			ew32(IMC, ~0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3987
			E1000_WRITE_FLUSH();
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
		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
  3990
			adapter->total_tx_bytes = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3991
			adapter->total_tx_packets = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3992
			adapter->total_rx_bytes = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3993
			adapter->total_rx_packets = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3994
			__netif_rx_schedule(netdev, &adapter->napi);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3995
		} else
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3996
			/* 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
  3997
			 * 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
  3998
			e1000_irq_enable(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3999
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4000
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4001
	return IRQ_HANDLED;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4002
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4003
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4004
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4005
 * e1000_clean - NAPI Rx polling callback
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4006
 * @adapter: board private structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4007
 * EtherCAT: never called
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4008
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4009
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
  4010
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4011
	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
  4012
	struct net_device *poll_dev = adapter->netdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4013
	int tx_cleaned = 0, work_done = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4014
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4015
	/* Must NOT use netdev_priv macro here. */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4016
	adapter = poll_dev->priv;
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
	/* 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
  4019
	 * 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
  4020
	 * simultaneously.  A failure obtaining the lock means
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4021
	 * 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
  4022
	if (spin_trylock(&adapter->tx_queue_lock)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4023
		tx_cleaned = e1000_clean_tx_irq(adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4024
						&adapter->tx_ring[0]);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4025
		spin_unlock(&adapter->tx_queue_lock);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4026
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4027
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4028
	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
  4029
	                  &work_done, budget);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4030
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4031
	if (tx_cleaned)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4032
		work_done = budget;
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
	/* 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
  4035
	if (work_done < budget) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4036
		if (likely(adapter->itr_setting & 3))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4037
			e1000_set_itr(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4038
		netif_rx_complete(poll_dev, napi);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4039
		e1000_irq_enable(adapter);
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
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4042
	return work_done;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4043
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4044
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4045
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4046
 * 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
  4047
 * @adapter: board private structure
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
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
  4050
			       struct e1000_tx_ring *tx_ring)
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
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4053
	struct net_device *netdev = adapter->netdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4054
	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
  4055
	struct e1000_buffer *buffer_info;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4056
	unsigned int i, eop;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4057
	unsigned int count = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4058
	bool cleaned = false;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4059
	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
  4060
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4061
	i = tx_ring->next_to_clean;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4062
	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
  4063
	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
  4064
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4065
	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
  4066
		for (cleaned = false; !cleaned; ) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4067
			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
  4068
			buffer_info = &tx_ring->buffer_info[i];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4069
			cleaned = (i == eop);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4070
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4071
			if (cleaned) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4072
				struct sk_buff *skb = buffer_info->skb;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4073
				unsigned int segs, bytecount;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4074
				segs = skb_shinfo(skb)->gso_segs ?: 1;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4075
				/* multiply data chunks by size of headers */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4076
				bytecount = ((segs - 1) * skb_headlen(skb)) +
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4077
				            skb->len;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4078
				total_tx_packets += segs;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4079
				total_tx_bytes += bytecount;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4080
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4081
			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
  4082
			tx_desc->upper.data = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4083
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4084
			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
  4085
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4086
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4087
		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
  4088
		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
  4089
#define E1000_TX_WEIGHT 64
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4090
		/* 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
  4091
		if (count++ == E1000_TX_WEIGHT)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4092
			break;
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
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4095
	tx_ring->next_to_clean = i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4096
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4097
#define TX_WAKE_THRESHOLD 32
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4098
	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
  4099
		     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
  4100
		/* 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
  4101
		 * sees the new next_to_clean.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4102
		 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4103
		smp_mb();
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4104
		if (netif_queue_stopped(netdev)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4105
			netif_wake_queue(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4106
			++adapter->restart_queue;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4107
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4108
	}
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
	if (!adapter->ecdev && adapter->detect_tx_hung) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4111
		/* 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
  4112
		 * 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
  4113
		adapter->detect_tx_hung = false;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4114
		if (tx_ring->buffer_info[eop].dma &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4115
		    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
  4116
		               (adapter->tx_timeout_factor * HZ))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4117
		    && !(er32(STATUS) & E1000_STATUS_TXOFF)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4118
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4119
			/* detected Tx unit hang */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4120
			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
  4121
					"  Tx Queue             <%lu>\n"
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4122
					"  TDH                  <%x>\n"
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4123
					"  TDT                  <%x>\n"
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4124
					"  next_to_use          <%x>\n"
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4125
					"  next_to_clean        <%x>\n"
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4126
					"buffer_info[next_to_clean]\n"
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4127
					"  time_stamp           <%lx>\n"
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4128
					"  next_to_watch        <%x>\n"
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4129
					"  jiffies              <%lx>\n"
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4130
					"  next_to_watch.status <%x>\n",
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4131
				(unsigned long)((tx_ring - adapter->tx_ring) /
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4132
					sizeof(struct e1000_tx_ring)),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4133
				readl(hw->hw_addr + tx_ring->tdh),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4134
				readl(hw->hw_addr + tx_ring->tdt),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4135
				tx_ring->next_to_use,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4136
				tx_ring->next_to_clean,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4137
				tx_ring->buffer_info[eop].time_stamp,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4138
				eop,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4139
				jiffies,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4140
				eop_desc->upper.fields.status);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4141
			netif_stop_queue(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4142
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4143
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4144
	adapter->total_tx_bytes += total_tx_bytes;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4145
	adapter->total_tx_packets += total_tx_packets;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4146
	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
  4147
	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
  4148
	return cleaned;
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
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4152
 * 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
  4153
 * @adapter:     board private structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4154
 * @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
  4155
 * @csum:        receive descriptor csum field
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4156
 * @sk_buff:     socket buffer with received data
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
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
  4160
			      u32 csum, struct sk_buff *skb)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4161
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4162
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4163
	u16 status = (u16)status_err;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4164
	u8 errors = (u8)(status_err >> 24);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4165
	skb->ip_summed = CHECKSUM_NONE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4166
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4167
	/* 82543 or newer only */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4168
	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
  4169
	/* Ignore Checksum bit is set */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4170
	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
  4171
	/* TCP/UDP checksum error bit is set */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4172
	if (unlikely(errors & E1000_RXD_ERR_TCPE)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4173
		/* let the stack verify checksum errors */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4174
		adapter->hw_csum_err++;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4175
		return;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4176
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4177
	/* TCP/UDP Checksum has not been calculated */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4178
	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
  4179
		if (!(status & E1000_RXD_STAT_TCPCS))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4180
			return;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4181
	} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4182
		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
  4183
			return;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4184
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4185
	/* 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
  4186
	if (likely(status & E1000_RXD_STAT_TCPCS)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4187
		/* TCP checksum is good */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4188
		skb->ip_summed = CHECKSUM_UNNECESSARY;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4189
	} 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
  4190
		/* IP fragment with UDP payload */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4191
		/* 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
  4192
		 * 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
  4193
		 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4194
		__sum16 sum = (__force __sum16)htons(csum);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4195
		skb->csum = csum_unfold(~sum);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4196
		skb->ip_summed = CHECKSUM_COMPLETE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4197
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4198
	adapter->hw_csum_good++;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4199
}
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
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4202
 * 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
  4203
 * @adapter: board private structure
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
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
  4206
			       struct e1000_rx_ring *rx_ring,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4207
			       int *work_done, int work_to_do)
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
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4210
	struct net_device *netdev = adapter->netdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4211
	struct pci_dev *pdev = adapter->pdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4212
	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
  4213
	struct e1000_buffer *buffer_info, *next_buffer;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4214
	unsigned long flags;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4215
	u32 length;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4216
	u8 last_byte;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4217
	unsigned int i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4218
	int cleaned_count = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4219
	bool cleaned = false;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4220
	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
  4221
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4222
	i = rx_ring->next_to_clean;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4223
	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
  4224
	buffer_info = &rx_ring->buffer_info[i];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4225
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4226
	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
  4227
		struct sk_buff *skb;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4228
		u8 status;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4229
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4230
		if (*work_done >= work_to_do)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4231
			break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4232
		(*work_done)++;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4233
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4234
		status = rx_desc->status;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4235
		skb = buffer_info->skb;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4236
		if (!adapter->ecdev) buffer_info->skb = NULL;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4237
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4238
		prefetch(skb->data - NET_IP_ALIGN);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4239
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4240
		if (++i == rx_ring->count) i = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4241
		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
  4242
		prefetch(next_rxd);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4243
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4244
		next_buffer = &rx_ring->buffer_info[i];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4245
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4246
		cleaned = true;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4247
		cleaned_count++;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4248
		pci_unmap_single(pdev,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4249
		                 buffer_info->dma,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4250
		                 buffer_info->length,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4251
		                 PCI_DMA_FROMDEVICE);
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
		length = le16_to_cpu(rx_desc->length);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4254
		/* !EOP means multiple descriptors were used to store a single
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4255
		 * packet, if thats the case we need to toss it.  In fact, we
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4256
		 * to toss every packet with the EOP bit clear and the next
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4257
		 * frame that _does_ have the EOP bit set, as it is by
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4258
		 * definition only a frame fragment
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
		if (unlikely(!(status & E1000_RXD_STAT_EOP)))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4261
			set_bit(__E1000_DISCARDING, &adapter->flags);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4262
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4263
		if (test_bit(__E1000_DISCARDING, &adapter->flags)) {
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
			if (status & E1000_RXD_STAT_EOP)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4270
				clear_bit(__E1000_DISCARDING, &adapter->flags);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4271
			goto next_desc;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4272
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4273
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4274
		if (!adapter->ecdev &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4275
                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
  4276
			last_byte = *(skb->data + length - 1);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4277
			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
  4278
				       last_byte)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4279
				spin_lock_irqsave(&adapter->stats_lock, flags);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4280
				e1000_tbi_adjust_stats(hw, &adapter->stats,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4281
				                       length, skb->data);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4282
				spin_unlock_irqrestore(&adapter->stats_lock,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4283
				                       flags);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4284
				length--;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4285
			} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4286
				/* recycle */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4287
				buffer_info->skb = skb;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4288
				goto next_desc;
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
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4291
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4292
		/* 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
  4293
		 * done after the TBI_ACCEPT workaround above */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4294
		length -= 4;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4295
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4296
		/* 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
  4297
		total_rx_bytes += length;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4298
		total_rx_packets++;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4299
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4300
		/* code added for copybreak, this should improve
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4301
		 * performance for small packets with large amounts
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4302
		 * of reassembly being done in the stack */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4303
		if (!adapter->ecdev && length < copybreak) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4304
			struct sk_buff *new_skb =
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4305
			    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
  4306
			if (new_skb) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4307
				skb_reserve(new_skb, NET_IP_ALIGN);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4308
				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
  4309
							       -NET_IP_ALIGN,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4310
							       (skb->data -
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
							       (length +
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4313
							        NET_IP_ALIGN));
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4314
				/* 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
  4315
				buffer_info->skb = skb;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4316
				skb = new_skb;
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
			/* else just continue with the old one */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4319
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4320
		/* end copybreak code */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4321
		skb_put(skb, length);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4322
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4323
		/* Receive Checksum Offload */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4324
		e1000_rx_checksum(adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4325
				  (u32)(status) |
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4326
				  ((u32)(rx_desc->errors) << 24),
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4327
				  le16_to_cpu(rx_desc->csum), skb);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4328
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4329
		if (adapter->ecdev) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4330
			ecdev_receive(adapter->ecdev, skb->data, length);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4331
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4332
			// No need to detect link status as
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4333
			// long as frames are received: Reset watchdog.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4334
			adapter->ec_watchdog_jiffies = jiffies;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4335
		} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4336
			skb->protocol = eth_type_trans(skb, netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4337
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4338
			if (unlikely(adapter->vlgrp &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4339
						(status & E1000_RXD_STAT_VP))) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4340
				vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4341
						le16_to_cpu(rx_desc->special));
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4342
			} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4343
				netif_receive_skb(skb);
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
		}
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
		netdev->last_rx = jiffies;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4348
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4349
next_desc:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4350
		rx_desc->status = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4351
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4352
		/* 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
  4353
		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
  4354
			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
  4355
			cleaned_count = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4356
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4357
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4358
		/* use prefetched values */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4359
		rx_desc = next_rxd;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4360
		buffer_info = next_buffer;
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
	rx_ring->next_to_clean = i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4363
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4364
	cleaned_count = E1000_DESC_UNUSED(rx_ring);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4365
	if (cleaned_count)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4366
		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
  4367
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4368
	adapter->total_rx_packets += total_rx_packets;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4369
	adapter->total_rx_bytes += total_rx_bytes;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4370
	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
  4371
	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
  4372
	return cleaned;
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
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4375
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4376
 * 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
  4377
 * @adapter: board private structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4378
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4379
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4380
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
  4381
				  struct e1000_rx_ring *rx_ring,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4382
				  int *work_done, int work_to_do)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4383
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4384
	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
  4385
	struct net_device *netdev = adapter->netdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4386
	struct pci_dev *pdev = adapter->pdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4387
	struct e1000_buffer *buffer_info, *next_buffer;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4388
	struct e1000_ps_page *ps_page;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4389
	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
  4390
	struct sk_buff *skb;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4391
	unsigned int i, j;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4392
	u32 length, staterr;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4393
	int cleaned_count = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4394
	bool cleaned = false;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4395
	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
  4396
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4397
	i = rx_ring->next_to_clean;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4398
	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
  4399
	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
  4400
	buffer_info = &rx_ring->buffer_info[i];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4401
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4402
	while (staterr & E1000_RXD_STAT_DD) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4403
		ps_page = &rx_ring->ps_page[i];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4404
		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
  4405
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4406
		if (unlikely(*work_done >= work_to_do))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4407
			break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4408
		(*work_done)++;
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
		skb = buffer_info->skb;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4411
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4412
		/* 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
  4413
		prefetch(skb->data - NET_IP_ALIGN);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4414
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4415
		if (++i == rx_ring->count) i = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4416
		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
  4417
		prefetch(next_rxd);
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
		next_buffer = &rx_ring->buffer_info[i];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4420
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4421
		cleaned = true;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4422
		cleaned_count++;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4423
		pci_unmap_single(pdev, buffer_info->dma,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4424
				 buffer_info->length,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4425
				 PCI_DMA_FROMDEVICE);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4426
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4427
		if (unlikely(!(staterr & E1000_RXD_STAT_EOP))) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4428
			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
  4429
				  " the full packet\n", netdev->name);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4430
			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
  4431
			goto next_desc;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4432
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4433
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4434
		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
  4435
			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
  4436
			goto next_desc;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4437
		}
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
		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
  4440
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4441
		if (unlikely(!length)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4442
			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
  4443
				  " multiple descriptors\n", netdev->name);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4444
			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
  4445
			goto next_desc;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4446
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4447
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4448
		/* Good Receive */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4449
		skb_put(skb, length);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4450
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4451
		{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4452
		/* 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
  4453
		   more efficient than reusing j */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4454
		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
  4455
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4456
		/* 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
  4457
		 * 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
  4458
		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
  4459
			u8 *vaddr;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4460
			/* 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
  4461
			 * 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
  4462
			 * very long */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4463
			pci_dma_sync_single_for_cpu(pdev,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4464
				ps_page_dma->ps_page_dma[0],
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4465
				PAGE_SIZE,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4466
				PCI_DMA_FROMDEVICE);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4467
			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
  4468
			                    KM_SKB_DATA_SOFTIRQ);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4469
			memcpy(skb_tail_pointer(skb), vaddr, l1);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4470
			kunmap_atomic(vaddr, KM_SKB_DATA_SOFTIRQ);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4471
			pci_dma_sync_single_for_device(pdev,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4472
				ps_page_dma->ps_page_dma[0],
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4473
				PAGE_SIZE, PCI_DMA_FROMDEVICE);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4474
			/* remove the CRC */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4475
			l1 -= 4;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4476
			skb_put(skb, l1);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4477
			goto copydone;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4478
		} /* if */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4479
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4480
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4481
		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
  4482
			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
  4483
			if (!length)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4484
				break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4485
			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
  4486
					PAGE_SIZE, PCI_DMA_FROMDEVICE);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4487
			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
  4488
			skb_add_rx_frag(skb, j, ps_page->ps_page[j], 0, length);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4489
			ps_page->ps_page[j] = NULL;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4490
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4491
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4492
		/* 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
  4493
		 * 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
  4494
		pskb_trim(skb, skb->len - 4);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4495
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4496
copydone:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4497
		total_rx_bytes += skb->len;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4498
		total_rx_packets++;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4499
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4500
		e1000_rx_checksum(adapter, staterr,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4501
				  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
  4502
		if (adapter->ecdev) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4503
			ecdev_receive(adapter->ecdev, skb->data, length);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4504
		} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4505
			skb->protocol = eth_type_trans(skb, netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4506
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4507
			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
  4508
				   cpu_to_le16(E1000_RXDPS_HDRSTAT_HDRSP)))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4509
				adapter->rx_hdr_split++;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4510
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4511
			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
  4512
				vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4513
					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
  4514
			} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4515
				netif_receive_skb(skb);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4516
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4517
		}
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
		netdev->last_rx = jiffies;
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
next_desc:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4522
		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
  4523
 		if (!adapter->ecdev) buffer_info->skb = NULL;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4524
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4525
		/* 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
  4526
		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
  4527
			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
  4528
			cleaned_count = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4529
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4530
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4531
		/* use prefetched values */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4532
		rx_desc = next_rxd;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4533
		buffer_info = next_buffer;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4534
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4535
		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
  4536
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4537
	rx_ring->next_to_clean = i;
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
	cleaned_count = E1000_DESC_UNUSED(rx_ring);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4540
	if (cleaned_count)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4541
		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
  4542
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4543
	adapter->total_rx_packets += total_rx_packets;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4544
	adapter->total_rx_bytes += total_rx_bytes;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4545
	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
  4546
	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
  4547
	return cleaned;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4548
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4549
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
 * 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
  4552
 * @adapter: address of board private structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4553
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4554
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4555
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
  4556
				   struct e1000_rx_ring *rx_ring,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4557
				   int cleaned_count)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4558
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4559
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4560
	struct net_device *netdev = adapter->netdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4561
	struct pci_dev *pdev = adapter->pdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4562
	struct e1000_rx_desc *rx_desc;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4563
	struct e1000_buffer *buffer_info;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4564
	struct sk_buff *skb;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4565
	unsigned int i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4566
	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
  4567
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4568
	i = rx_ring->next_to_use;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4569
	buffer_info = &rx_ring->buffer_info[i];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4570
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4571
	while (cleaned_count--) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4572
		skb = buffer_info->skb;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4573
		if (skb) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4574
			skb_trim(skb, 0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4575
			goto map_skb;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4576
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4577
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4578
		skb = netdev_alloc_skb(netdev, bufsz);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4579
		if (unlikely(!skb)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4580
			/* Better luck next round */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4581
			adapter->alloc_rx_buff_failed++;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4582
			break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4583
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4584
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4585
		/* 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
  4586
		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
  4587
			struct sk_buff *oldskb = skb;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4588
			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
  4589
					     "at %p\n", bufsz, skb->data);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4590
			/* Try again, without freeing the previous */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4591
			skb = netdev_alloc_skb(netdev, bufsz);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4592
			/* Failed allocation, critical failure */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4593
			if (!skb) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4594
				dev_kfree_skb(oldskb);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4595
				break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4596
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4597
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4598
			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
  4599
				/* give up */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4600
				dev_kfree_skb(skb);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4601
				dev_kfree_skb(oldskb);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4602
				break; /* while !buffer_info->skb */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4603
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4604
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4605
			/* Use new allocation */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4606
			dev_kfree_skb(oldskb);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4607
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4608
		/* 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
  4609
		 * 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
  4610
		 * the 14 byte MAC header is removed
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4611
		 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4612
		skb_reserve(skb, NET_IP_ALIGN);
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
		buffer_info->skb = skb;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4615
		buffer_info->length = adapter->rx_buffer_len;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4616
map_skb:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4617
		buffer_info->dma = pci_map_single(pdev,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4618
						  skb->data,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4619
						  adapter->rx_buffer_len,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4620
						  PCI_DMA_FROMDEVICE);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4621
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4622
		/* 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
  4623
		if (!e1000_check_64k_bound(adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4624
					(void *)(unsigned long)buffer_info->dma,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4625
					adapter->rx_buffer_len)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4626
			DPRINTK(RX_ERR, ERR,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4627
				"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
  4628
				adapter->rx_buffer_len,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4629
				(void *)(unsigned long)buffer_info->dma);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4630
			if (!adapter->ecdev) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4631
				dev_kfree_skb(skb);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4632
				buffer_info->skb = NULL;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4633
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4634
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4635
			pci_unmap_single(pdev, buffer_info->dma,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4636
					 adapter->rx_buffer_len,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4637
					 PCI_DMA_FROMDEVICE);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4638
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4639
			break; /* while !buffer_info->skb */
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
		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
  4642
		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
  4643
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4644
		if (unlikely(++i == rx_ring->count))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4645
			i = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4646
		buffer_info = &rx_ring->buffer_info[i];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4647
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4648
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4649
	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
  4650
		rx_ring->next_to_use = i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4651
		if (unlikely(i-- == 0))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4652
			i = (rx_ring->count - 1);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4653
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4654
		/* 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
  4655
		 * 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
  4656
		 * applicable for weak-ordered memory model archs,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4657
		 * such as IA-64). */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4658
		wmb();
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4659
		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
  4660
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4661
}
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
 * 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
  4665
 * @adapter: address of board private structure
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4666
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4667
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4668
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
  4669
				      struct e1000_rx_ring *rx_ring,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4670
				      int cleaned_count)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4671
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4672
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4673
	struct net_device *netdev = adapter->netdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4674
	struct pci_dev *pdev = adapter->pdev;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4675
	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
  4676
	struct e1000_buffer *buffer_info;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4677
	struct e1000_ps_page *ps_page;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4678
	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
  4679
	struct sk_buff *skb;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4680
	unsigned int i, j;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4681
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4682
	i = rx_ring->next_to_use;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4683
	buffer_info = &rx_ring->buffer_info[i];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4684
	ps_page = &rx_ring->ps_page[i];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4685
	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
  4686
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4687
	while (cleaned_count--) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4688
		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
  4689
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4690
		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
  4691
			if (j < adapter->rx_ps_pages) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4692
				if (likely(!ps_page->ps_page[j])) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4693
					ps_page->ps_page[j] =
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4694
						netdev_alloc_page(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4695
					if (unlikely(!ps_page->ps_page[j])) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4696
						adapter->alloc_rx_buff_failed++;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4697
						goto no_buffers;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4698
					}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4699
					ps_page_dma->ps_page_dma[j] =
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4700
						pci_map_page(pdev,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4701
							    ps_page->ps_page[j],
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4702
							    0, PAGE_SIZE,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4703
							    PCI_DMA_FROMDEVICE);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4704
				}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4705
				/* 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
  4706
				 * change because each write-back erases
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4707
				 * this info.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4708
				 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4709
				rx_desc->read.buffer_addr[j+1] =
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4710
				     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
  4711
			} else
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4712
				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
  4713
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4714
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4715
		skb = netdev_alloc_skb(netdev,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4716
		                       adapter->rx_ps_bsize0 + NET_IP_ALIGN);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4717
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4718
		if (unlikely(!skb)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4719
			adapter->alloc_rx_buff_failed++;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4720
			break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4721
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4722
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4723
		/* 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
  4724
		 * 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
  4725
		 * the 14 byte MAC header is removed
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4726
		 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4727
		skb_reserve(skb, NET_IP_ALIGN);
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
		buffer_info->skb = skb;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4730
		buffer_info->length = adapter->rx_ps_bsize0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4731
		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
  4732
						  adapter->rx_ps_bsize0,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4733
						  PCI_DMA_FROMDEVICE);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4734
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4735
		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
  4736
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4737
		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
  4738
		buffer_info = &rx_ring->buffer_info[i];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4739
		ps_page = &rx_ring->ps_page[i];
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4740
		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
  4741
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4742
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4743
no_buffers:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4744
	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
  4745
		rx_ring->next_to_use = i;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4746
		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
  4747
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4748
		/* 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
  4749
		 * 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
  4750
		 * applicable for weak-ordered memory model archs,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4751
		 * such as IA-64). */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4752
		wmb();
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4753
		/* 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
  4754
		 * 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
  4755
		 * twice as much.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4756
		 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4757
		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
  4758
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4759
}
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
 * 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
  4763
 * @adapter:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4764
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4765
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4766
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
  4767
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4768
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4769
	u16 phy_status;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4770
	u16 phy_ctrl;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4771
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4772
	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
  4773
	   !(hw->autoneg_advertised & ADVERTISE_1000_FULL))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4774
		return;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4775
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4776
	if (adapter->smartspeed == 0) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4777
		/* 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
  4778
		 * we assume back-to-back */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4779
		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
  4780
		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
  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_CTRL, &phy_ctrl);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4784
		if (phy_ctrl & CR_1000T_MS_ENABLE) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4785
			phy_ctrl &= ~CR_1000T_MS_ENABLE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4786
			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
  4787
					    phy_ctrl);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4788
			adapter->smartspeed++;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4789
			if (!e1000_phy_setup_autoneg(hw) &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4790
			   !e1000_read_phy_reg(hw, PHY_CTRL,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4791
				   	       &phy_ctrl)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4792
				phy_ctrl |= (MII_CR_AUTO_NEG_EN |
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4793
					     MII_CR_RESTART_AUTO_NEG);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4794
				e1000_write_phy_reg(hw, PHY_CTRL,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4795
						    phy_ctrl);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4796
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4797
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4798
		return;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4799
	} else if (adapter->smartspeed == E1000_SMARTSPEED_DOWNSHIFT) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4800
		/* 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
  4801
		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
  4802
		phy_ctrl |= CR_1000T_MS_ENABLE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4803
		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
  4804
		if (!e1000_phy_setup_autoneg(hw) &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4805
		   !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
  4806
			phy_ctrl |= (MII_CR_AUTO_NEG_EN |
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4807
				     MII_CR_RESTART_AUTO_NEG);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4808
			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
  4809
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4810
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4811
	/* Restart process after E1000_SMARTSPEED_MAX iterations */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4812
	if (adapter->smartspeed++ == E1000_SMARTSPEED_MAX)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4813
		adapter->smartspeed = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4814
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4815
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
 * e1000_ioctl -
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4818
 * @netdev:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4819
 * @ifreq:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4820
 * @cmd:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4821
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4822
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4823
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
  4824
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4825
	switch (cmd) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4826
	case SIOCGMIIPHY:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4827
	case SIOCGMIIREG:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4828
	case SIOCSMIIREG:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4829
		return e1000_mii_ioctl(netdev, ifr, cmd);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4830
	default:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4831
		return -EOPNOTSUPP;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4832
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4833
}
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
 * e1000_mii_ioctl -
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4837
 * @netdev:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4838
 * @ifreq:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4839
 * @cmd:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4840
 **/
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4841
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4842
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
  4843
			   int cmd)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4844
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4845
	struct e1000_adapter *adapter = netdev_priv(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4846
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4847
	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
  4848
	int retval;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4849
	u16 mii_reg;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4850
	u16 spddplx;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4851
	unsigned long flags;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4852
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4853
	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
  4854
		return -EOPNOTSUPP;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4855
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4856
	switch (cmd) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4857
	case SIOCGMIIPHY:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4858
		data->phy_id = hw->phy_addr;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4859
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4860
	case SIOCGMIIREG:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4861
		if (adapter->ecdev || !capable(CAP_NET_ADMIN))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4862
			return -EPERM;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4863
		spin_lock_irqsave(&adapter->stats_lock, flags);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4864
		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
  4865
				   &data->val_out)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4866
			spin_unlock_irqrestore(&adapter->stats_lock, flags);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4867
			return -EIO;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4868
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4869
		spin_unlock_irqrestore(&adapter->stats_lock, flags);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4870
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4871
	case SIOCSMIIREG:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4872
		if (adapter->ecdev || !capable(CAP_NET_ADMIN))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4873
			return -EPERM;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4874
		if (data->reg_num & ~(0x1F))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4875
			return -EFAULT;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4876
		mii_reg = data->val_in;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4877
		spin_lock_irqsave(&adapter->stats_lock, flags);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4878
		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
  4879
					mii_reg)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4880
			spin_unlock_irqrestore(&adapter->stats_lock, flags);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4881
			return -EIO;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4882
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4883
		spin_unlock_irqrestore(&adapter->stats_lock, flags);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4884
		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
  4885
			switch (data->reg_num) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4886
			case PHY_CTRL:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4887
				if (mii_reg & MII_CR_POWER_DOWN)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4888
					break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4889
				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
  4890
					hw->autoneg = 1;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4891
					hw->autoneg_advertised = 0x2F;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4892
				} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4893
					if (mii_reg & 0x40)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4894
						spddplx = SPEED_1000;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4895
					else if (mii_reg & 0x2000)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4896
						spddplx = SPEED_100;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4897
					else
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4898
						spddplx = SPEED_10;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4899
					spddplx += (mii_reg & 0x100)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4900
						   ? DUPLEX_FULL :
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4901
						   DUPLEX_HALF;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4902
					retval = e1000_set_spd_dplx(adapter,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4903
								    spddplx);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4904
					if (retval)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4905
						return retval;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4906
				}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4907
				if (netif_running(adapter->netdev))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4908
					e1000_reinit_locked(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4909
				else
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4910
					e1000_reset(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4911
				break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4912
			case M88E1000_PHY_SPEC_CTRL:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4913
			case M88E1000_EXT_PHY_SPEC_CTRL:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4914
				if (e1000_phy_reset(hw))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4915
					return -EIO;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4916
				break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4917
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4918
		} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4919
			switch (data->reg_num) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4920
			case PHY_CTRL:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4921
				if (mii_reg & MII_CR_POWER_DOWN)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4922
					break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4923
				if (netif_running(adapter->netdev))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4924
					e1000_reinit_locked(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4925
				else
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4926
					e1000_reset(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4927
				break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4928
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4929
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4930
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4931
	default:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4932
		return -EOPNOTSUPP;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4933
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4934
	return E1000_SUCCESS;
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
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4937
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
  4938
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4939
	struct e1000_adapter *adapter = hw->back;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4940
	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
  4941
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4942
	if (ret_val)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4943
		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
  4944
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4945
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4946
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
  4947
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4948
	struct e1000_adapter *adapter = hw->back;
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
	pci_clear_mwi(adapter->pdev);
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
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4953
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
  4954
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4955
	struct e1000_adapter *adapter = hw->back;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4956
	return pcix_get_mmrbc(adapter->pdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4957
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4958
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4959
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
  4960
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4961
	struct e1000_adapter *adapter = hw->back;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4962
	pcix_set_mmrbc(adapter->pdev, mmrbc);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4963
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4964
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4965
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
  4966
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4967
    struct e1000_adapter *adapter = hw->back;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4968
    u16 cap_offset;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4969
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4970
    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
  4971
    if (!cap_offset)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4972
        return -E1000_ERR_CONFIG;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4973
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4974
    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
  4975
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4976
    return E1000_SUCCESS;
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
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4979
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
  4980
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4981
	outl(value, port);
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
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4984
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
  4985
				   struct vlan_group *grp)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4986
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4987
	struct e1000_adapter *adapter = netdev_priv(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4988
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4989
	u32 ctrl, rctl;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4990
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4991
	if (!test_bit(__E1000_DOWN, &adapter->flags))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4992
		e1000_irq_disable(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4993
	adapter->vlgrp = grp;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4994
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4995
	if (grp) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4996
		/* enable VLAN tag insert/strip */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4997
		ctrl = er32(CTRL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4998
		ctrl |= E1000_CTRL_VME;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4999
		ew32(CTRL, ctrl);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5000
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5001
		if (adapter->hw.mac_type != e1000_ich8lan) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5002
			/* enable VLAN receive filtering */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5003
			rctl = er32(RCTL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5004
			rctl &= ~E1000_RCTL_CFIEN;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5005
			ew32(RCTL, rctl);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5006
			e1000_update_mng_vlan(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5007
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5008
	} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5009
		/* disable VLAN tag insert/strip */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5010
		ctrl = er32(CTRL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5011
		ctrl &= ~E1000_CTRL_VME;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5012
		ew32(CTRL, ctrl);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5013
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5014
		if (adapter->hw.mac_type != e1000_ich8lan) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5015
			if (adapter->mng_vlan_id !=
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5016
			    (u16)E1000_MNG_VLAN_NONE) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5017
				e1000_vlan_rx_kill_vid(netdev,
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5018
				                       adapter->mng_vlan_id);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5019
				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
  5020
			}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5021
		}
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
	if (!test_bit(__E1000_DOWN, &adapter->flags))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5025
		e1000_irq_enable(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5026
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5027
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5028
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
  5029
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5030
	struct e1000_adapter *adapter = netdev_priv(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5031
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5032
	u32 vfta, index;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5033
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5034
	if ((hw->mng_cookie.status &
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5035
	     E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5036
	    (vid == adapter->mng_vlan_id))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5037
		return;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5038
	/* add VID to filter table */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5039
	index = (vid >> 5) & 0x7F;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5040
	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
  5041
	vfta |= (1 << (vid & 0x1F));
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5042
	e1000_write_vfta(hw, index, vfta);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5043
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5044
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5045
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
  5046
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5047
	struct e1000_adapter *adapter = netdev_priv(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5048
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5049
	u32 vfta, index;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5050
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5051
	if (!test_bit(__E1000_DOWN, &adapter->flags))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5052
		e1000_irq_disable(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5053
	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
  5054
	if (!test_bit(__E1000_DOWN, &adapter->flags))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5055
		e1000_irq_enable(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5056
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5057
	if ((hw->mng_cookie.status &
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5058
	     E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5059
	    (vid == adapter->mng_vlan_id)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5060
		/* release control to f/w */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5061
		e1000_release_hw_control(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5062
		return;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5063
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5064
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5065
	/* remove VID from filter table */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5066
	index = (vid >> 5) & 0x7F;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5067
	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
  5068
	vfta &= ~(1 << (vid & 0x1F));
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5069
	e1000_write_vfta(hw, index, vfta);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5070
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5071
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5072
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
  5073
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5074
	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
  5075
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5076
	if (adapter->vlgrp) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5077
		u16 vid;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5078
		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
  5079
			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
  5080
				continue;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5081
			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
  5082
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5083
	}
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
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
  5087
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5088
	struct e1000_hw *hw = &adapter->hw;
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
	hw->autoneg = 0;
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
	/* 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
  5093
	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
  5094
		spddplx != (SPEED_1000 + DUPLEX_FULL)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5095
		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
  5096
		return -EINVAL;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5097
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5098
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5099
	switch (spddplx) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5100
	case SPEED_10 + DUPLEX_HALF:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5101
		hw->forced_speed_duplex = e1000_10_half;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5102
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5103
	case SPEED_10 + DUPLEX_FULL:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5104
		hw->forced_speed_duplex = e1000_10_full;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5105
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5106
	case SPEED_100 + DUPLEX_HALF:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5107
		hw->forced_speed_duplex = e1000_100_half;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5108
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5109
	case SPEED_100 + DUPLEX_FULL:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5110
		hw->forced_speed_duplex = e1000_100_full;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5111
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5112
	case SPEED_1000 + DUPLEX_FULL:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5113
		hw->autoneg = 1;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5114
		hw->autoneg_advertised = ADVERTISE_1000_FULL;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5115
		break;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5116
	case SPEED_1000 + DUPLEX_HALF: /* not supported */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5117
	default:
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5118
		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
  5119
		return -EINVAL;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5120
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5121
	return 0;
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
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5124
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
  5125
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5126
	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
  5127
	struct e1000_adapter *adapter = netdev_priv(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5128
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5129
	u32 ctrl, ctrl_ext, rctl, status;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5130
	u32 wufc = adapter->wol;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5131
#ifdef CONFIG_PM
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5132
	int retval = 0;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5133
#endif
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5134
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5135
	if (adapter->ecdev)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5136
		return -EBUSY;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5137
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5138
	netif_device_detach(netdev);
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
	if (netif_running(netdev)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5141
		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
  5142
		e1000_down(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5143
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5144
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5145
#ifdef CONFIG_PM
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5146
	retval = pci_save_state(pdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5147
	if (retval)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5148
		return retval;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5149
#endif
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5150
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5151
	status = er32(STATUS);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5152
	if (status & E1000_STATUS_LU)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5153
		wufc &= ~E1000_WUFC_LNKC;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5154
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5155
	if (wufc) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5156
		e1000_setup_rctl(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5157
		e1000_set_rx_mode(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5158
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5159
		/* 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
  5160
		if (wufc & E1000_WUFC_MC) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5161
			rctl = er32(RCTL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5162
			rctl |= E1000_RCTL_MPE;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5163
			ew32(RCTL, rctl);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5164
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5165
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5166
		if (hw->mac_type >= e1000_82540) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5167
			ctrl = er32(CTRL);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5168
			/* advertise wake from D3Cold */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5169
			#define E1000_CTRL_ADVD3WUC 0x00100000
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5170
			/* phy power management enable */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5171
			#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
  5172
			ctrl |= E1000_CTRL_ADVD3WUC |
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5173
				E1000_CTRL_EN_PHY_PWR_MGMT;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5174
			ew32(CTRL, ctrl);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5175
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5176
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5177
		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
  5178
		   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
  5179
			/* keep the laser running in D3 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5180
			ctrl_ext = er32(CTRL_EXT);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5181
			ctrl_ext |= E1000_CTRL_EXT_SDP7_DATA;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5182
			ew32(CTRL_EXT, ctrl_ext);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5183
		}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5184
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5185
		/* 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
  5186
		e1000_disable_pciex_master(hw);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5187
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5188
		ew32(WUC, E1000_WUC_PME_EN);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5189
		ew32(WUFC, wufc);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5190
		pci_enable_wake(pdev, PCI_D3hot, 1);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5191
		pci_enable_wake(pdev, PCI_D3cold, 1);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5192
	} else {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5193
		ew32(WUC, 0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5194
		ew32(WUFC, 0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5195
		pci_enable_wake(pdev, PCI_D3hot, 0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5196
		pci_enable_wake(pdev, PCI_D3cold, 0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5197
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5198
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5199
	e1000_release_manageability(adapter);
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
	/* 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
  5202
	if (adapter->en_mng_pt) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5203
		pci_enable_wake(pdev, PCI_D3hot, 1);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5204
		pci_enable_wake(pdev, PCI_D3cold, 1);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5205
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5206
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5207
	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
  5208
		e1000_phy_powerdown_workaround(hw);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5209
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5210
	if (netif_running(netdev))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5211
		e1000_free_irq(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5212
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5213
	/* 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
  5214
	 * 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
  5215
	e1000_release_hw_control(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5216
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5217
	pci_disable_device(pdev);
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_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
  5220
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5221
	return 0;
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
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5224
#ifdef CONFIG_PM
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5225
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
  5226
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5227
	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
  5228
	struct e1000_adapter *adapter = netdev_priv(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5229
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5230
	u32 err;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5231
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5232
	if (adapter->ecdev)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5233
		return -EBUSY;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5234
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5235
	pci_set_power_state(pdev, PCI_D0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5236
	pci_restore_state(pdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5237
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5238
	if (adapter->need_ioport)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5239
		err = pci_enable_device(pdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5240
	else
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5241
		err = pci_enable_device_mem(pdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5242
	if (err) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5243
		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
  5244
		return err;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5245
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5246
	pci_set_master(pdev);
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_enable_wake(pdev, PCI_D3hot, 0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5249
	pci_enable_wake(pdev, PCI_D3cold, 0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5250
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5251
	if (netif_running(netdev)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5252
		err = e1000_request_irq(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5253
		if (err)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5254
			return err;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5255
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5256
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5257
	e1000_power_up_phy(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5258
	e1000_reset(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5259
	ew32(WUS, ~0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5260
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5261
	e1000_init_manageability(adapter);
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
	if (netif_running(netdev))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5264
		e1000_up(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5265
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5266
	if (!adapter->ecdev) netif_device_attach(netdev);
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 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
  5269
	 * 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
  5270
	 * 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
  5271
	 * of the driver. */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5272
	if (hw->mac_type != e1000_82573 ||
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5273
	    !e1000_check_mng_mode(hw))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5274
		e1000_get_hw_control(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5275
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5276
	return 0;
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
#endif
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
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
  5281
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5282
	e1000_suspend(pdev, PMSG_SUSPEND);
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
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5285
#ifdef CONFIG_NET_POLL_CONTROLLER
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
 * 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
  5288
 * 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
  5289
 * the interrupt routine is executing.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5290
 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5291
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
  5292
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5293
	struct e1000_adapter *adapter = netdev_priv(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
	disable_irq(adapter->pdev->irq);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5296
	e1000_intr(adapter->pdev->irq, netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5297
	enable_irq(adapter->pdev->irq);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5298
}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5299
#endif
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
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5302
 * 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
  5303
 * @pdev: Pointer to PCI device
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5304
 * @state: The current pci conneection state
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5305
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5306
 * 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
  5307
 * this device has been detected.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5308
 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5309
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
  5310
						pci_channel_state_t state)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5311
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5312
	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
  5313
	struct e1000_adapter *adapter = netdev->priv;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5314
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5315
	netif_device_detach(netdev);
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
	if (state == pci_channel_io_perm_failure)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5318
		return PCI_ERS_RESULT_DISCONNECT;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5319
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5320
	if (netif_running(netdev))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5321
		e1000_down(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5322
	pci_disable_device(pdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5323
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5324
	/* Request a slot slot reset. */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5325
	return PCI_ERS_RESULT_NEED_RESET;
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
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5329
 * 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
  5330
 * @pdev: Pointer to PCI device
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5331
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5332
 * 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
  5333
 * 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
  5334
 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5335
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
  5336
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5337
	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
  5338
	struct e1000_adapter *adapter = netdev->priv;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5339
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5340
	int err;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5341
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5342
	if (adapter->need_ioport)
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5343
		err = pci_enable_device(pdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5344
	else
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5345
		err = pci_enable_device_mem(pdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5346
	if (err) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5347
		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
  5348
		return PCI_ERS_RESULT_DISCONNECT;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5349
	}
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5350
	pci_set_master(pdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5351
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5352
	pci_enable_wake(pdev, PCI_D3hot, 0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5353
	pci_enable_wake(pdev, PCI_D3cold, 0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5354
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5355
	e1000_reset(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5356
	ew32(WUS, ~0);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5357
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5358
	return PCI_ERS_RESULT_RECOVERED;
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
/**
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5362
 * 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
  5363
 * @pdev: Pointer to PCI device
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5364
 *
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5365
 * 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
  5366
 * 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
  5367
 * second-half of the e1000_resume routine.
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5368
 */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5369
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
  5370
{
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5371
	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
  5372
	struct e1000_adapter *adapter = netdev->priv;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5373
	struct e1000_hw *hw = &adapter->hw;
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5374
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5375
	e1000_init_manageability(adapter);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5376
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5377
	if (netif_running(netdev)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5378
		if (e1000_up(adapter)) {
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5379
			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
  5380
			return;
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
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5384
	netif_device_attach(netdev);
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5385
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5386
	/* 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
  5387
	 * 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
  5388
	 * 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
  5389
	 * of the driver. */
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5390
	if (hw->mac_type != e1000_82573 ||
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5391
	    !e1000_check_mng_mode(hw))
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5392
		e1000_get_hw_control(adapter);
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
25f848e2fbf4 Added e1000 driver for 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5396
/* e1000_main.c */