devices/e1000/e1000_main-2.6.13-ethercat.c
author Florian Pose <fp@igh-essen.com>
Wed, 12 Sep 2007 13:20:29 +0000
changeset 717 87abf1166e88
parent 677 7c7cf2d6c911
child 724 f188f8a0cafd
permissions -rw-r--r--
Clear station addresses with broadcast before setting them.
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/*******************************************************************************
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
  
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
  Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     5
  
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     6
  This program is free software; you can redistribute it and/or modify it 
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     7
  under the terms of the GNU General Public License as published by the Free 
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
  Software Foundation; either version 2 of the License, or (at your option) 
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     9
  any later version.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    10
  
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    11
  This program is distributed in the hope that it will be useful, but WITHOUT 
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    12
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for 
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    14
  more details.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    15
  
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    16
  You should have received a copy of the GNU General Public License along with
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    17
  this program; if not, write to the Free Software Foundation, Inc., 59 
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    18
  Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    19
  
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    20
  The full GNU General Public License is included in this distribution in the
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    21
  file called LICENSE.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    22
  
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    23
  Contact Information:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    24
  Linux NICS <linux.nics@intel.com>
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    25
  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    26
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    27
*******************************************************************************/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    28
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
#include "e1000-2.6.13-ethercat.h"
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
/* Change Log
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
 * 6.0.58       4/20/05
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
 *   o Accepted ethtool cleanup patch from Stephen Hemminger 
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
 * 6.0.44+	2/15/05
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
 *   o applied Anton's patch to resolve tx hang in hardware
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
 *   o Applied Andrew Mortons patch - e1000 stops working after resume
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    39
char e1000_driver_name[] = "ec_e1000";
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
static char e1000_driver_string[] = "EtherCAT Intel(R) PRO/1000 Network Driver";
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
#ifndef CONFIG_E1000_NAPI
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
#define DRIVERNAPI
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
#else
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
#define DRIVERNAPI "-NAPI"
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
#define DRV_VERSION		"6.0.60-k2"DRIVERNAPI
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
char e1000_driver_version[] = DRV_VERSION;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    48
char e1000_copyright[] = "Copyright (c) 1999-2005 Intel Corporation.";
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    49
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    50
/* e1000_pci_tbl - PCI Device ID Table
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    51
 *
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    52
 * Last entry must be all 0s
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    53
 *
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    54
 * Macro expands to...
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    55
 *   {PCI_DEVICE(PCI_VENDOR_ID_INTEL, device_id)}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    56
 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    57
static struct pci_device_id e1000_pci_tbl[] = {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    58
	INTEL_E1000_ETHERNET_DEVICE(0x1000),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    59
	INTEL_E1000_ETHERNET_DEVICE(0x1001),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    60
	INTEL_E1000_ETHERNET_DEVICE(0x1004),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    61
	INTEL_E1000_ETHERNET_DEVICE(0x1008),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    62
	INTEL_E1000_ETHERNET_DEVICE(0x1009),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    63
	INTEL_E1000_ETHERNET_DEVICE(0x100C),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    64
	INTEL_E1000_ETHERNET_DEVICE(0x100D),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    65
	INTEL_E1000_ETHERNET_DEVICE(0x100E),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    66
	INTEL_E1000_ETHERNET_DEVICE(0x100F),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    67
	INTEL_E1000_ETHERNET_DEVICE(0x1010),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    68
	INTEL_E1000_ETHERNET_DEVICE(0x1011),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    69
	INTEL_E1000_ETHERNET_DEVICE(0x1012),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    70
	INTEL_E1000_ETHERNET_DEVICE(0x1013),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    71
	INTEL_E1000_ETHERNET_DEVICE(0x1014),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    72
	INTEL_E1000_ETHERNET_DEVICE(0x1015),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    73
	INTEL_E1000_ETHERNET_DEVICE(0x1016),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    74
	INTEL_E1000_ETHERNET_DEVICE(0x1017),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    75
	INTEL_E1000_ETHERNET_DEVICE(0x1018),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    76
	INTEL_E1000_ETHERNET_DEVICE(0x1019),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    77
	INTEL_E1000_ETHERNET_DEVICE(0x101A),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    78
	INTEL_E1000_ETHERNET_DEVICE(0x101D),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    79
	INTEL_E1000_ETHERNET_DEVICE(0x101E),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    80
	INTEL_E1000_ETHERNET_DEVICE(0x1026),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    81
	INTEL_E1000_ETHERNET_DEVICE(0x1027),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    82
	INTEL_E1000_ETHERNET_DEVICE(0x1028),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    83
	INTEL_E1000_ETHERNET_DEVICE(0x1075),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    84
	INTEL_E1000_ETHERNET_DEVICE(0x1076),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    85
	INTEL_E1000_ETHERNET_DEVICE(0x1077),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    86
	INTEL_E1000_ETHERNET_DEVICE(0x1078),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    87
	INTEL_E1000_ETHERNET_DEVICE(0x1079),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    88
	INTEL_E1000_ETHERNET_DEVICE(0x107A),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    89
	INTEL_E1000_ETHERNET_DEVICE(0x107B),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    90
	INTEL_E1000_ETHERNET_DEVICE(0x107C),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    91
	INTEL_E1000_ETHERNET_DEVICE(0x108A),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    92
	INTEL_E1000_ETHERNET_DEVICE(0x108B),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    93
	INTEL_E1000_ETHERNET_DEVICE(0x108C),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    94
	INTEL_E1000_ETHERNET_DEVICE(0x1099),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    95
	/* required last entry */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    96
	{0,}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    97
};
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    98
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    99
// do not auto-load driver
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   100
// MODULE_DEVICE_TABLE(pci, e1000_pci_tbl);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   101
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   102
int e1000_up(struct e1000_adapter *adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   103
void e1000_down(struct e1000_adapter *adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   104
void e1000_reset(struct e1000_adapter *adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   105
int e1000_set_spd_dplx(struct e1000_adapter *adapter, uint16_t spddplx);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   106
int e1000_setup_tx_resources(struct e1000_adapter *adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   107
int e1000_setup_rx_resources(struct e1000_adapter *adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   108
void e1000_free_tx_resources(struct e1000_adapter *adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   109
void e1000_free_rx_resources(struct e1000_adapter *adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   110
void e1000_update_stats(struct e1000_adapter *adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   111
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   112
/* Local Function Prototypes */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   113
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   114
static int e1000_init_module(void);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   115
static void e1000_exit_module(void);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   116
static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   117
static void __devexit e1000_remove(struct pci_dev *pdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   118
static int e1000_sw_init(struct e1000_adapter *adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   119
static int e1000_open(struct net_device *netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   120
static int e1000_close(struct net_device *netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   121
static void e1000_configure_tx(struct e1000_adapter *adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   122
static void e1000_configure_rx(struct e1000_adapter *adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   123
static void e1000_setup_rctl(struct e1000_adapter *adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   124
static void e1000_clean_tx_ring(struct e1000_adapter *adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   125
static void e1000_clean_rx_ring(struct e1000_adapter *adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   126
static void e1000_set_multi(struct net_device *netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   127
static void e1000_update_phy_info(unsigned long data);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   128
static void e1000_watchdog(unsigned long data);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   129
static void e1000_watchdog_task(struct e1000_adapter *adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   130
static void e1000_82547_tx_fifo_stall(unsigned long data);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   131
static int e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   132
static struct net_device_stats * e1000_get_stats(struct net_device *netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   133
static int e1000_change_mtu(struct net_device *netdev, int new_mtu);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   134
static int e1000_set_mac(struct net_device *netdev, void *p);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   135
void ec_poll(struct net_device *);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   136
static irqreturn_t e1000_intr(int irq, void *data, struct pt_regs *regs);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   137
static boolean_t e1000_clean_tx_irq(struct e1000_adapter *adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   138
#ifdef CONFIG_E1000_NAPI
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   139
static int e1000_clean(struct net_device *netdev, int *budget);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   140
static boolean_t e1000_clean_rx_irq(struct e1000_adapter *adapter,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   141
                                    int *work_done, int work_to_do);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   142
static boolean_t e1000_clean_rx_irq_ps(struct e1000_adapter *adapter,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   143
                                       int *work_done, int work_to_do);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   144
#else
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   145
static boolean_t e1000_clean_rx_irq(struct e1000_adapter *adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   146
static boolean_t e1000_clean_rx_irq_ps(struct e1000_adapter *adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   147
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   148
static void e1000_alloc_rx_buffers(struct e1000_adapter *adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   149
static void e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   150
static int e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   151
static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   152
			   int cmd);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   153
void e1000_set_ethtool_ops(struct net_device *netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   154
static void e1000_enter_82542_rst(struct e1000_adapter *adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   155
static void e1000_leave_82542_rst(struct e1000_adapter *adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   156
static void e1000_tx_timeout(struct net_device *dev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   157
static void e1000_tx_timeout_task(struct net_device *dev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   158
static void e1000_smartspeed(struct e1000_adapter *adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   159
static inline int e1000_82547_fifo_workaround(struct e1000_adapter *adapter,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   160
					      struct sk_buff *skb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   161
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   162
static void e1000_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   163
static void e1000_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   164
static void e1000_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   165
static void e1000_restore_vlan(struct e1000_adapter *adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   166
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   167
static int e1000_suspend(struct pci_dev *pdev, uint32_t state);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   168
#ifdef CONFIG_PM
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   169
static int e1000_resume(struct pci_dev *pdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   170
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   171
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   172
#ifdef CONFIG_NET_POLL_CONTROLLER
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   173
/* for netdump / net console */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   174
static void e1000_netpoll (struct net_device *netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   175
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   176
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   177
/* Exported from other modules */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   178
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   179
extern void e1000_check_options(struct e1000_adapter *adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   180
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   181
static struct pci_driver e1000_driver = {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   182
	.name     = e1000_driver_name,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   183
	.id_table = e1000_pci_tbl,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   184
	.probe    = e1000_probe,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   185
	.remove   = __devexit_p(e1000_remove),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   186
	/* Power Managment Hooks */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   187
#ifdef CONFIG_PM
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   188
	.suspend  = e1000_suspend,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   189
	.resume   = e1000_resume
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   190
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   191
};
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   192
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   193
MODULE_AUTHOR("Florian Pose <fp@igh-essen.com>");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   194
MODULE_DESCRIPTION("EtherCAT-capable Intel(R) PRO/1000 Network Driver");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   195
MODULE_LICENSE("GPL");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   196
MODULE_VERSION(DRV_VERSION);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   197
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   198
static int debug = NETIF_MSG_DRV | NETIF_MSG_PROBE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   199
module_param(debug, int, 0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   200
MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   201
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   202
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   203
 * e1000_init_module - Driver Registration Routine
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   204
 *
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   205
 * e1000_init_module is the first routine called when the driver is
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   206
 * loaded. All it does is register with the PCI subsystem.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   207
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   208
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   209
static int __init
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   210
e1000_init_module(void)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   211
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   212
	int ret;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   213
	printk(KERN_INFO "%s - version %s\n",
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   214
	       e1000_driver_string, e1000_driver_version);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   215
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   216
	printk(KERN_INFO "%s\n", e1000_copyright);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   217
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   218
	ret = pci_module_init(&e1000_driver);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   219
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   220
	return ret;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   221
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   222
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   223
module_init(e1000_init_module);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   224
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   225
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   226
 * e1000_exit_module - Driver Exit Cleanup Routine
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   227
 *
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   228
 * e1000_exit_module is called just before the driver is removed
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   229
 * from memory.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   230
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   231
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   232
static void __exit
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   233
e1000_exit_module(void)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   234
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   235
	pci_unregister_driver(&e1000_driver);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   236
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   237
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   238
module_exit(e1000_exit_module);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   239
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   240
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   241
 * e1000_irq_disable - Mask off interrupt generation on the NIC
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   242
 * @adapter: board private structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   243
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   244
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   245
static inline void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   246
e1000_irq_disable(struct e1000_adapter *adapter)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   247
{
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
   248
    if (adapter->ecdev)
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
   249
        return;
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   250
	atomic_inc(&adapter->irq_sem);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   251
	E1000_WRITE_REG(&adapter->hw, IMC, ~0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   252
	E1000_WRITE_FLUSH(&adapter->hw);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   253
	synchronize_irq(adapter->pdev->irq);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   254
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   255
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   256
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   257
 * e1000_irq_enable - Enable default interrupt generation settings
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   258
 * @adapter: board private structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   259
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   260
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   261
static inline void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   262
e1000_irq_enable(struct e1000_adapter *adapter)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   263
{
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
   264
    if (adapter->ecdev)
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
   265
        return;
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
   266
	if(likely(atomic_dec_and_test(&adapter->irq_sem))) {
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   267
		E1000_WRITE_REG(&adapter->hw, IMS, IMS_ENABLE_MASK);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   268
		E1000_WRITE_FLUSH(&adapter->hw);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   269
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   270
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   271
void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   272
e1000_update_mng_vlan(struct e1000_adapter *adapter)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   273
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   274
	struct net_device *netdev = adapter->netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   275
	uint16_t vid = adapter->hw.mng_cookie.vlan_id;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   276
	uint16_t old_vid = adapter->mng_vlan_id;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   277
	if(adapter->vlgrp) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   278
		if(!adapter->vlgrp->vlan_devices[vid]) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   279
			if(adapter->hw.mng_cookie.status &
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   280
				E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   281
				e1000_vlan_rx_add_vid(netdev, vid);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   282
				adapter->mng_vlan_id = vid;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   283
			} else
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   284
				adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   285
				
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   286
			if((old_vid != (uint16_t)E1000_MNG_VLAN_NONE) &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   287
					(vid != old_vid) && 
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   288
					!adapter->vlgrp->vlan_devices[old_vid])
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   289
				e1000_vlan_rx_kill_vid(netdev, old_vid);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   290
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   291
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   292
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   293
	
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   294
int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   295
e1000_up(struct e1000_adapter *adapter)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   296
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   297
	struct net_device *netdev = adapter->netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   298
	int err;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   299
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   300
	/* hardware has been reset, we need to reload some things */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   301
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   302
	/* Reset the PHY if it was previously powered down */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   303
	if(adapter->hw.media_type == e1000_media_type_copper) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   304
		uint16_t mii_reg;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   305
		e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &mii_reg);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   306
		if(mii_reg & MII_CR_POWER_DOWN)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   307
			e1000_phy_reset(&adapter->hw);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   308
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   309
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   310
	e1000_set_multi(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   311
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   312
	e1000_restore_vlan(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   313
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   314
	e1000_configure_tx(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   315
	e1000_setup_rctl(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   316
	e1000_configure_rx(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   317
	adapter->alloc_rx_buf(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   318
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   319
#ifdef CONFIG_PCI_MSI
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   320
	if(adapter->hw.mac_type > e1000_82547_rev_2) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   321
		adapter->have_msi = TRUE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   322
		if((err = pci_enable_msi(adapter->pdev))) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   323
			DPRINTK(PROBE, ERR,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   324
			 "Unable to allocate MSI interrupt Error: %d\n", err);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   325
			adapter->have_msi = FALSE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   326
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   327
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   328
#endif
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
   329
    if (!adapter->ecdev) {
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
   330
        if((err = request_irq(adapter->pdev->irq, &e1000_intr,
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
   331
                        SA_SHIRQ | SA_SAMPLE_RANDOM,
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
   332
                        netdev->name, netdev))) {
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
   333
            DPRINTK(PROBE, ERR,
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
   334
                    "Unable to allocate interrupt Error: %d\n", err);
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
   335
            return err;
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
   336
        }
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
   337
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
   338
        mod_timer(&adapter->watchdog_timer, jiffies);
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   339
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   340
#ifdef CONFIG_E1000_NAPI
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
   341
        netif_poll_enable(netdev);
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   342
#endif
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
   343
        e1000_irq_enable(adapter);
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
   344
    }
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   345
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   346
	return 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   347
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   348
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   349
void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   350
e1000_down(struct e1000_adapter *adapter)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   351
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   352
	struct net_device *netdev = adapter->netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   353
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
   354
    if (!adapter->ecdev) {
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
   355
        e1000_irq_disable(adapter);
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
   356
        free_irq(adapter->pdev->irq, netdev);
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
   357
    }
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   358
#ifdef CONFIG_PCI_MSI
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   359
	if(adapter->hw.mac_type > e1000_82547_rev_2 &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   360
	   adapter->have_msi == TRUE)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   361
		pci_disable_msi(adapter->pdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   362
#endif
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
   363
    if (!adapter->ecdev) {
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
   364
        del_timer_sync(&adapter->tx_fifo_stall_timer);
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
   365
        del_timer_sync(&adapter->watchdog_timer);
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
   366
        del_timer_sync(&adapter->phy_info_timer);
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   367
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   368
#ifdef CONFIG_E1000_NAPI
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
   369
        netif_poll_disable(netdev);
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   370
#endif
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
   371
    }
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   372
	adapter->link_speed = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   373
	adapter->link_duplex = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   374
	if (!adapter->ecdev) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   375
		netif_carrier_off(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   376
		netif_stop_queue(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   377
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   378
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   379
	e1000_reset(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   380
	e1000_clean_tx_ring(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   381
	e1000_clean_rx_ring(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   382
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   383
	/* If WoL is not enabled
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   384
	 * and management mode is not IAMT
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   385
	 * Power down the PHY so no link is implied when interface is down */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   386
	if(!adapter->wol && adapter->hw.mac_type >= e1000_82540 &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   387
	   adapter->hw.media_type == e1000_media_type_copper &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   388
	   !e1000_check_mng_mode(&adapter->hw) &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   389
	   !(E1000_READ_REG(&adapter->hw, MANC) & E1000_MANC_SMBUS_EN)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   390
		uint16_t mii_reg;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   391
		e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &mii_reg);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   392
		mii_reg |= MII_CR_POWER_DOWN;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   393
		e1000_write_phy_reg(&adapter->hw, PHY_CTRL, mii_reg);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   394
		mdelay(1);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   395
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   396
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   397
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   398
void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   399
e1000_reset(struct e1000_adapter *adapter)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   400
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   401
	struct net_device *netdev = adapter->netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   402
	uint32_t pba, manc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   403
	uint16_t fc_high_water_mark = E1000_FC_HIGH_DIFF;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   404
	uint16_t fc_low_water_mark = E1000_FC_LOW_DIFF;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   405
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   406
	/* Repartition Pba for greater than 9k mtu
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   407
	 * To take effect CTRL.RST is required.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   408
	 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   409
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   410
	switch (adapter->hw.mac_type) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   411
	case e1000_82547:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   412
	case e1000_82547_rev_2:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   413
		pba = E1000_PBA_30K;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   414
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   415
	case e1000_82573:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   416
		pba = E1000_PBA_12K;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   417
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   418
	default:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   419
		pba = E1000_PBA_48K;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   420
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   421
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   422
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   423
	if((adapter->hw.mac_type != e1000_82573) &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   424
	   (adapter->rx_buffer_len > E1000_RXBUFFER_8192)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   425
		pba -= 8; /* allocate more FIFO for Tx */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   426
		/* send an XOFF when there is enough space in the
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   427
		 * Rx FIFO to hold one extra full size Rx packet 
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   428
		*/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   429
		fc_high_water_mark = netdev->mtu + ENET_HEADER_SIZE + 
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   430
					ETHERNET_FCS_SIZE + 1;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   431
		fc_low_water_mark = fc_high_water_mark + 8;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   432
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   433
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   434
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   435
	if(adapter->hw.mac_type == e1000_82547) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   436
		adapter->tx_fifo_head = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   437
		adapter->tx_head_addr = pba << E1000_TX_HEAD_ADDR_SHIFT;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   438
		adapter->tx_fifo_size =
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   439
			(E1000_PBA_40K - pba) << E1000_PBA_BYTES_SHIFT;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   440
		atomic_set(&adapter->tx_fifo_stall, 0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   441
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   442
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   443
	E1000_WRITE_REG(&adapter->hw, PBA, pba);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   444
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   445
	/* flow control settings */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   446
	adapter->hw.fc_high_water = (pba << E1000_PBA_BYTES_SHIFT) -
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   447
				    fc_high_water_mark;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   448
	adapter->hw.fc_low_water = (pba << E1000_PBA_BYTES_SHIFT) -
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   449
				   fc_low_water_mark;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   450
	adapter->hw.fc_pause_time = E1000_FC_PAUSE_TIME;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   451
	adapter->hw.fc_send_xon = 1;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   452
	adapter->hw.fc = adapter->hw.original_fc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   453
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   454
	/* Allow time for pending master requests to run */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   455
	e1000_reset_hw(&adapter->hw);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   456
	if(adapter->hw.mac_type >= e1000_82544)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   457
		E1000_WRITE_REG(&adapter->hw, WUC, 0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   458
	if(e1000_init_hw(&adapter->hw))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   459
		DPRINTK(PROBE, ERR, "Hardware Error\n");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   460
	e1000_update_mng_vlan(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   461
	/* Enable h/w to recognize an 802.1Q VLAN Ethernet packet */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   462
	E1000_WRITE_REG(&adapter->hw, VET, ETHERNET_IEEE_VLAN_TYPE);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   463
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   464
	e1000_reset_adaptive(&adapter->hw);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   465
	e1000_phy_get_info(&adapter->hw, &adapter->phy_info);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   466
	if (adapter->en_mng_pt) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   467
		manc = E1000_READ_REG(&adapter->hw, MANC);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   468
		manc |= (E1000_MANC_ARP_EN | E1000_MANC_EN_MNG2HOST);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   469
		E1000_WRITE_REG(&adapter->hw, MANC, manc);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   470
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   471
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   472
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   473
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   474
 * e1000_probe - Device Initialization Routine
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   475
 * @pdev: PCI device information struct
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   476
 * @ent: entry in e1000_pci_tbl
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   477
 *
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   478
 * Returns 0 on success, negative on failure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   479
 *
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   480
 * e1000_probe initializes an adapter identified by a pci_dev structure.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   481
 * The OS initialization, configuring of the adapter private structure,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   482
 * and a hardware reset occur.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   483
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   484
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   485
static int __devinit
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   486
e1000_probe(struct pci_dev *pdev,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   487
            const struct pci_device_id *ent)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   488
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   489
	struct net_device *netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   490
	struct e1000_adapter *adapter;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   491
	unsigned long mmio_start, mmio_len;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   492
	uint32_t swsm;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   493
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   494
	static int cards_found = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   495
	int i, err, pci_using_dac;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   496
	uint16_t eeprom_data;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   497
	uint16_t eeprom_apme_mask = E1000_EEPROM_APME;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   498
	if((err = pci_enable_device(pdev)))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   499
		return err;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   500
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   501
	if(!(err = pci_set_dma_mask(pdev, DMA_64BIT_MASK))) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   502
		pci_using_dac = 1;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   503
	} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   504
		if((err = pci_set_dma_mask(pdev, DMA_32BIT_MASK))) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   505
			E1000_ERR("No usable DMA configuration, aborting\n");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   506
			return err;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   507
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   508
		pci_using_dac = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   509
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   510
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   511
	if((err = pci_request_regions(pdev, e1000_driver_name)))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   512
		return err;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   513
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   514
	pci_set_master(pdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   515
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   516
	netdev = alloc_etherdev(sizeof(struct e1000_adapter));
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   517
	if(!netdev) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   518
		err = -ENOMEM;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   519
		goto err_alloc_etherdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   520
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   521
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   522
	SET_MODULE_OWNER(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   523
	SET_NETDEV_DEV(netdev, &pdev->dev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   524
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   525
	pci_set_drvdata(pdev, netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   526
	adapter = netdev_priv(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   527
	adapter->netdev = netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   528
	adapter->pdev = pdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   529
	adapter->hw.back = adapter;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   530
	adapter->msg_enable = (1 << debug) - 1;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   531
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   532
	mmio_start = pci_resource_start(pdev, BAR_0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   533
	mmio_len = pci_resource_len(pdev, BAR_0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   534
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   535
	adapter->hw.hw_addr = ioremap(mmio_start, mmio_len);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   536
	if(!adapter->hw.hw_addr) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   537
		err = -EIO;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   538
		goto err_ioremap;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   539
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   540
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   541
	for(i = BAR_1; i <= BAR_5; i++) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   542
		if(pci_resource_len(pdev, i) == 0)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   543
			continue;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   544
		if(pci_resource_flags(pdev, i) & IORESOURCE_IO) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   545
			adapter->hw.io_base = pci_resource_start(pdev, i);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   546
			break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   547
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   548
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   549
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   550
	netdev->open = &e1000_open;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   551
	netdev->stop = &e1000_close;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   552
	netdev->hard_start_xmit = &e1000_xmit_frame;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   553
	netdev->get_stats = &e1000_get_stats;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   554
	netdev->set_multicast_list = &e1000_set_multi;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   555
	netdev->set_mac_address = &e1000_set_mac;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   556
	netdev->change_mtu = &e1000_change_mtu;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   557
	netdev->do_ioctl = &e1000_ioctl;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   558
	e1000_set_ethtool_ops(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   559
	netdev->tx_timeout = &e1000_tx_timeout;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   560
	netdev->watchdog_timeo = 5 * HZ;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   561
#ifdef CONFIG_E1000_NAPI
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   562
	netdev->poll = &e1000_clean;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   563
	netdev->weight = 64;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   564
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   565
	netdev->vlan_rx_register = e1000_vlan_rx_register;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   566
	netdev->vlan_rx_add_vid = e1000_vlan_rx_add_vid;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   567
	netdev->vlan_rx_kill_vid = e1000_vlan_rx_kill_vid;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   568
#ifdef CONFIG_NET_POLL_CONTROLLER
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   569
	netdev->poll_controller = e1000_netpoll;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   570
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   571
	strcpy(netdev->name, pci_name(pdev));
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   572
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   573
	netdev->mem_start = mmio_start;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   574
	netdev->mem_end = mmio_start + mmio_len;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   575
	netdev->base_addr = adapter->hw.io_base;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   576
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   577
	adapter->bd_number = cards_found;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   578
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   579
	/* setup the private structure */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   580
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   581
	if((err = e1000_sw_init(adapter)))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   582
		goto err_sw_init;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   583
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   584
	if((err = e1000_check_phy_reset_block(&adapter->hw)))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   585
		DPRINTK(PROBE, INFO, "PHY reset is blocked due to SOL/IDER session.\n");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   586
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   587
	if(adapter->hw.mac_type >= e1000_82543) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   588
		netdev->features = NETIF_F_SG |
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   589
				   NETIF_F_HW_CSUM |
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   590
				   NETIF_F_HW_VLAN_TX |
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   591
				   NETIF_F_HW_VLAN_RX |
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   592
				   NETIF_F_HW_VLAN_FILTER;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   593
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   594
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   595
#ifdef NETIF_F_TSO
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   596
	if((adapter->hw.mac_type >= e1000_82544) &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   597
	   (adapter->hw.mac_type != e1000_82547))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   598
		netdev->features |= NETIF_F_TSO;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   599
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   600
#ifdef NETIF_F_TSO_IPV6
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   601
	if(adapter->hw.mac_type > e1000_82547_rev_2)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   602
		netdev->features |= NETIF_F_TSO_IPV6;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   603
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   604
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   605
	if(pci_using_dac)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   606
		netdev->features |= NETIF_F_HIGHDMA;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   607
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   608
 	/* hard_start_xmit is safe against parallel locking */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   609
 	netdev->features |= NETIF_F_LLTX; 
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   610
 
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   611
	adapter->en_mng_pt = e1000_enable_mng_pass_thru(&adapter->hw);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   612
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   613
	/* before reading the EEPROM, reset the controller to 
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   614
	 * put the device in a known good starting state */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   615
	
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   616
	e1000_reset_hw(&adapter->hw);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   617
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   618
	/* make sure the EEPROM is good */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   619
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   620
	if(e1000_validate_eeprom_checksum(&adapter->hw) < 0) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   621
		DPRINTK(PROBE, ERR, "The EEPROM Checksum Is Not Valid\n");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   622
		err = -EIO;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   623
		goto err_eeprom;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   624
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   625
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   626
	/* copy the MAC address out of the EEPROM */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   627
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   628
	if(e1000_read_mac_addr(&adapter->hw))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   629
		DPRINTK(PROBE, ERR, "EEPROM Read Error\n");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   630
	memcpy(netdev->dev_addr, adapter->hw.mac_addr, netdev->addr_len);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   631
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   632
	if(!is_valid_ether_addr(netdev->dev_addr)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   633
		DPRINTK(PROBE, ERR, "Invalid MAC Address\n");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   634
		err = -EIO;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   635
		goto err_eeprom;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   636
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   637
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   638
	e1000_read_part_num(&adapter->hw, &(adapter->part_num));
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   639
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   640
	e1000_get_bus_info(&adapter->hw);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   641
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   642
	init_timer(&adapter->tx_fifo_stall_timer);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   643
	adapter->tx_fifo_stall_timer.function = &e1000_82547_tx_fifo_stall;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   644
	adapter->tx_fifo_stall_timer.data = (unsigned long) adapter;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   645
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   646
	init_timer(&adapter->watchdog_timer);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   647
	adapter->watchdog_timer.function = &e1000_watchdog;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   648
	adapter->watchdog_timer.data = (unsigned long) adapter;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   649
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   650
	INIT_WORK(&adapter->watchdog_task,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   651
		(void (*)(void *))e1000_watchdog_task, adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   652
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   653
	init_timer(&adapter->phy_info_timer);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   654
	adapter->phy_info_timer.function = &e1000_update_phy_info;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   655
	adapter->phy_info_timer.data = (unsigned long) adapter;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   656
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   657
	INIT_WORK(&adapter->tx_timeout_task,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   658
		(void (*)(void *))e1000_tx_timeout_task, netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   659
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   660
	/* we're going to reset, so assume we have no link for now */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   661
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   662
	if (!adapter->ecdev) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   663
		netif_carrier_off(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   664
		netif_stop_queue(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   665
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   666
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   667
	e1000_check_options(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   668
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   669
	/* Initial Wake on LAN setting
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   670
	 * If APM wake is enabled in the EEPROM,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   671
	 * enable the ACPI Magic Packet filter
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   672
	 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   674
	switch(adapter->hw.mac_type) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   675
	case e1000_82542_rev2_0:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   676
	case e1000_82542_rev2_1:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   677
	case e1000_82543:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   678
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   679
	case e1000_82544:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   680
		e1000_read_eeprom(&adapter->hw,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   681
			EEPROM_INIT_CONTROL2_REG, 1, &eeprom_data);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   682
		eeprom_apme_mask = E1000_EEPROM_82544_APM;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   683
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   684
	case e1000_82546:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   685
	case e1000_82546_rev_3:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   686
		if((E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_FUNC_1)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   687
		   && (adapter->hw.media_type == e1000_media_type_copper)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   688
			e1000_read_eeprom(&adapter->hw,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   689
				EEPROM_INIT_CONTROL3_PORT_B, 1, &eeprom_data);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   690
			break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   691
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   692
		/* Fall Through */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   693
	default:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   694
		e1000_read_eeprom(&adapter->hw,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   695
			EEPROM_INIT_CONTROL3_PORT_A, 1, &eeprom_data);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   696
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   697
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   698
	if(eeprom_data & eeprom_apme_mask)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   699
		adapter->wol |= E1000_WUFC_MAG;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   700
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   701
	/* reset the hardware with the new settings */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   702
	e1000_reset(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   703
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   704
	/* Let firmware know the driver has taken over */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   705
	switch(adapter->hw.mac_type) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   706
	case e1000_82573:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   707
		swsm = E1000_READ_REG(&adapter->hw, SWSM);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   708
		E1000_WRITE_REG(&adapter->hw, SWSM,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   709
				swsm | E1000_SWSM_DRV_LOAD);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   710
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   711
	default:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   712
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   713
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   714
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   715
	// offer device to EtherCAT master module
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   716
	if (ecdev_offer(netdev, ec_poll, THIS_MODULE, &adapter->ecdev)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   717
		DPRINTK(PROBE, ERR, "Failed to offer device.\n");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   718
		goto err_register;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   719
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   720
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   721
	if (adapter->ecdev) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   722
		if (ecdev_open(adapter->ecdev)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   723
			ecdev_withdraw(adapter->ecdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   724
			goto err_register;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   725
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   726
	} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   727
		strcpy(netdev->name, "eth%d");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   728
		if ((err = register_netdev(netdev)))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   729
			goto err_register;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   730
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   731
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   732
	DPRINTK(PROBE, INFO, "Intel(R) PRO/1000 Network Connection\n");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   733
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   734
	cards_found++;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   735
	return 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   736
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   737
err_register:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   738
err_sw_init:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   739
err_eeprom:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   740
	iounmap(adapter->hw.hw_addr);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   741
err_ioremap:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   742
	free_netdev(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   743
err_alloc_etherdev:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   744
	pci_release_regions(pdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   745
	return err;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   746
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   747
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   748
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   749
 * e1000_remove - Device Removal Routine
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   750
 * @pdev: PCI device information struct
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   751
 *
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   752
 * e1000_remove is called by the PCI subsystem to alert the driver
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   753
 * that it should release a PCI device.  The could be caused by a
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   754
 * Hot-Plug event, or because the driver is going to be removed from
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   755
 * memory.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   756
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   757
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   758
static void __devexit
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   759
e1000_remove(struct pci_dev *pdev)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   760
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   761
	struct net_device *netdev = pci_get_drvdata(pdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   762
	struct e1000_adapter *adapter = netdev_priv(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   763
	uint32_t manc, swsm;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   764
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   765
	flush_scheduled_work();
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   766
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   767
	if(adapter->hw.mac_type >= e1000_82540 &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   768
	   adapter->hw.media_type == e1000_media_type_copper) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   769
		manc = E1000_READ_REG(&adapter->hw, MANC);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   770
		if(manc & E1000_MANC_SMBUS_EN) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   771
			manc |= E1000_MANC_ARP_EN;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   772
			E1000_WRITE_REG(&adapter->hw, MANC, manc);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   773
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   774
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   775
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   776
	switch(adapter->hw.mac_type) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   777
	case e1000_82573:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   778
		swsm = E1000_READ_REG(&adapter->hw, SWSM);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   779
		E1000_WRITE_REG(&adapter->hw, SWSM,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   780
				swsm & ~E1000_SWSM_DRV_LOAD);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   781
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   782
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   783
	default:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   784
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   785
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   786
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   787
	if (adapter->ecdev) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   788
		ecdev_close(adapter->ecdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   789
		ecdev_withdraw(adapter->ecdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   790
	} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   791
		unregister_netdev(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   792
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   793
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   794
	if(!e1000_check_phy_reset_block(&adapter->hw))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   795
		e1000_phy_hw_reset(&adapter->hw);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   796
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   797
	iounmap(adapter->hw.hw_addr);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   798
	pci_release_regions(pdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   799
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   800
	free_netdev(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   801
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   802
	pci_disable_device(pdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   803
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   804
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   805
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   806
 * e1000_sw_init - Initialize general software structures (struct e1000_adapter)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   807
 * @adapter: board private structure to initialize
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   808
 *
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   809
 * e1000_sw_init initializes the Adapter private data structure.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   810
 * Fields are initialized based on PCI device information and
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   811
 * OS network device settings (MTU size).
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   812
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   813
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   814
static int __devinit
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   815
e1000_sw_init(struct e1000_adapter *adapter)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   816
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   817
	struct e1000_hw *hw = &adapter->hw;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   818
	struct net_device *netdev = adapter->netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   819
	struct pci_dev *pdev = adapter->pdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   820
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   821
	/* PCI config space info */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   822
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   823
	hw->vendor_id = pdev->vendor;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   824
	hw->device_id = pdev->device;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   825
	hw->subsystem_vendor_id = pdev->subsystem_vendor;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   826
	hw->subsystem_id = pdev->subsystem_device;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   827
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   828
	pci_read_config_byte(pdev, PCI_REVISION_ID, &hw->revision_id);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   829
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   830
	pci_read_config_word(pdev, PCI_COMMAND, &hw->pci_cmd_word);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   831
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   832
	adapter->rx_buffer_len = E1000_RXBUFFER_2048;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   833
	adapter->rx_ps_bsize0 = E1000_RXBUFFER_256;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   834
	hw->max_frame_size = netdev->mtu +
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   835
			     ENET_HEADER_SIZE + ETHERNET_FCS_SIZE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   836
	hw->min_frame_size = MINIMUM_ETHERNET_FRAME_SIZE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   837
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   838
	/* identify the MAC */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   839
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   840
	if(e1000_set_mac_type(hw)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   841
		DPRINTK(PROBE, ERR, "Unknown MAC Type\n");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   842
		return -EIO;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   843
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   844
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   845
	/* initialize eeprom parameters */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   846
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   847
	if(e1000_init_eeprom_params(hw)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   848
		E1000_ERR("EEPROM initialization failed\n");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   849
		return -EIO;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   850
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   851
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   852
	switch(hw->mac_type) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   853
	default:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   854
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   855
	case e1000_82541:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   856
	case e1000_82547:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   857
	case e1000_82541_rev_2:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   858
	case e1000_82547_rev_2:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   859
		hw->phy_init_script = 1;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   860
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   861
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   862
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   863
	e1000_set_media_type(hw);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   864
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   865
	hw->wait_autoneg_complete = FALSE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   866
	hw->tbi_compatibility_en = TRUE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   867
	hw->adaptive_ifs = TRUE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   868
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   869
	/* Copper options */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   870
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   871
	if(hw->media_type == e1000_media_type_copper) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   872
		hw->mdix = AUTO_ALL_MODES;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   873
		hw->disable_polarity_correction = FALSE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   874
		hw->master_slave = E1000_MASTER_SLAVE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   875
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   876
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   877
	atomic_set(&adapter->irq_sem, 1);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   878
	spin_lock_init(&adapter->stats_lock);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   879
	spin_lock_init(&adapter->tx_lock);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   880
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   881
	return 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   882
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   883
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   884
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   885
 * e1000_open - Called when a network interface is made active
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   886
 * @netdev: network interface device structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   887
 *
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   888
 * Returns 0 on success, negative value on failure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   889
 *
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   890
 * The open entry point is called when a network interface is made
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   891
 * active by the system (IFF_UP).  At this point all resources needed
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   892
 * for transmit and receive operations are allocated, the interrupt
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   893
 * handler is registered with the OS, the watchdog timer is started,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   894
 * and the stack is notified that the interface is ready.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   895
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   896
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   897
static int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   898
e1000_open(struct net_device *netdev)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   899
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   900
	struct e1000_adapter *adapter = netdev_priv(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   901
	int err;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   902
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   903
	/* allocate transmit descriptors */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   904
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   905
	if((err = e1000_setup_tx_resources(adapter)))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   906
		goto err_setup_tx;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   907
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   908
	/* allocate receive descriptors */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   909
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   910
	if((err = e1000_setup_rx_resources(adapter)))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   911
		goto err_setup_rx;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   912
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   913
	if((err = e1000_up(adapter)))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   914
		goto err_up;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   915
	adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   916
	if((adapter->hw.mng_cookie.status &
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   917
			  E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   918
		e1000_update_mng_vlan(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   919
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   920
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   921
	return E1000_SUCCESS;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   922
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   923
err_up:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   924
	e1000_free_rx_resources(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   925
err_setup_rx:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   926
	e1000_free_tx_resources(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   927
err_setup_tx:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   928
	e1000_reset(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   929
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   930
	return err;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   931
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   932
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   933
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   934
 * e1000_close - Disables a network interface
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   935
 * @netdev: network interface device structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   936
 *
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   937
 * Returns 0, this is not allowed to fail
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   938
 *
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   939
 * The close entry point is called when an interface is de-activated
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   940
 * by the OS.  The hardware is still under the drivers control, but
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   941
 * needs to be disabled.  A global MAC reset is issued to stop the
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   942
 * hardware, and all transmit and receive resources are freed.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   943
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   944
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   945
static int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   946
e1000_close(struct net_device *netdev)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   947
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   948
	struct e1000_adapter *adapter = netdev_priv(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   949
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   950
	e1000_down(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   951
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   952
	e1000_free_tx_resources(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   953
	e1000_free_rx_resources(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   954
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   955
	if((adapter->hw.mng_cookie.status &
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   956
			  E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   957
		e1000_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   958
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   959
	return 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   960
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   961
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   962
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   963
 * e1000_check_64k_bound - check that memory doesn't cross 64kB boundary
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   964
 * @adapter: address of board private structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   965
 * @start: address of beginning of memory
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   966
 * @len: length of memory
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   967
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   968
static inline boolean_t
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   969
e1000_check_64k_bound(struct e1000_adapter *adapter,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   970
		      void *start, unsigned long len)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   971
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   972
	unsigned long begin = (unsigned long) start;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   973
	unsigned long end = begin + len;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   974
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   975
	/* First rev 82545 and 82546 need to not allow any memory
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   976
	 * write location to cross 64k boundary due to errata 23 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   977
	if (adapter->hw.mac_type == e1000_82545 ||
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   978
	    adapter->hw.mac_type == e1000_82546) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   979
		return ((begin ^ (end - 1)) >> 16) != 0 ? FALSE : TRUE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   980
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   981
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   982
	return TRUE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   983
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   984
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   985
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   986
 * e1000_setup_tx_resources - allocate Tx resources (Descriptors)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   987
 * @adapter: board private structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   988
 *
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   989
 * Return 0 on success, negative on failure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   990
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   991
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   992
int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   993
e1000_setup_tx_resources(struct e1000_adapter *adapter)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   994
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   995
	struct e1000_desc_ring *txdr = &adapter->tx_ring;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   996
	struct pci_dev *pdev = adapter->pdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   997
	int size;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   998
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   999
	size = sizeof(struct e1000_buffer) * txdr->count;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1000
	txdr->buffer_info = vmalloc(size);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1001
	if(!txdr->buffer_info) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1002
		DPRINTK(PROBE, ERR,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1003
		"Unable to allocate memory for the transmit descriptor ring\n");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1004
		return -ENOMEM;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1005
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1006
	memset(txdr->buffer_info, 0, size);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1007
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1008
	/* round up to nearest 4K */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1009
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1010
	txdr->size = txdr->count * sizeof(struct e1000_tx_desc);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1011
	E1000_ROUNDUP(txdr->size, 4096);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1012
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1013
	txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1014
	if(!txdr->desc) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1015
setup_tx_desc_die:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1016
		vfree(txdr->buffer_info);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1017
		DPRINTK(PROBE, ERR,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1018
		"Unable to allocate memory for the transmit descriptor ring\n");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1019
		return -ENOMEM;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1020
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1021
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1022
	/* Fix for errata 23, can't cross 64kB boundary */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1023
	if (!e1000_check_64k_bound(adapter, txdr->desc, txdr->size)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1024
		void *olddesc = txdr->desc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1025
		dma_addr_t olddma = txdr->dma;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1026
		DPRINTK(TX_ERR, ERR, "txdr align check failed: %u bytes "
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1027
				     "at %p\n", txdr->size, txdr->desc);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1028
		/* Try again, without freeing the previous */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1029
		txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1030
		if(!txdr->desc) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1031
		/* Failed allocation, critical failure */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1032
			pci_free_consistent(pdev, txdr->size, olddesc, olddma);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1033
			goto setup_tx_desc_die;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1034
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1035
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1036
		if (!e1000_check_64k_bound(adapter, txdr->desc, txdr->size)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1037
			/* give up */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1038
			pci_free_consistent(pdev, txdr->size, txdr->desc,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1039
					    txdr->dma);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1040
			pci_free_consistent(pdev, txdr->size, olddesc, olddma);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1041
			DPRINTK(PROBE, ERR,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1042
				"Unable to allocate aligned memory "
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1043
				"for the transmit descriptor ring\n");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1044
			vfree(txdr->buffer_info);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1045
			return -ENOMEM;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1046
		} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1047
			/* Free old allocation, new allocation was successful */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1048
			pci_free_consistent(pdev, txdr->size, olddesc, olddma);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1049
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1050
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1051
	memset(txdr->desc, 0, txdr->size);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1052
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1053
	txdr->next_to_use = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1054
	txdr->next_to_clean = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1055
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1056
	return 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1057
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1058
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1059
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1060
 * e1000_configure_tx - Configure 8254x Transmit Unit after Reset
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1061
 * @adapter: board private structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1062
 *
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1063
 * Configure the Tx unit of the MAC after a reset.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1064
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1065
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1066
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1067
e1000_configure_tx(struct e1000_adapter *adapter)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1068
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1069
	uint64_t tdba = adapter->tx_ring.dma;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1070
	uint32_t tdlen = adapter->tx_ring.count * sizeof(struct e1000_tx_desc);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1071
	uint32_t tctl, tipg;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1072
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1073
	E1000_WRITE_REG(&adapter->hw, TDBAL, (tdba & 0x00000000ffffffffULL));
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1074
	E1000_WRITE_REG(&adapter->hw, TDBAH, (tdba >> 32));
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1075
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1076
	E1000_WRITE_REG(&adapter->hw, TDLEN, tdlen);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1077
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1078
	/* Setup the HW Tx Head and Tail descriptor pointers */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1079
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1080
	E1000_WRITE_REG(&adapter->hw, TDH, 0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1081
	E1000_WRITE_REG(&adapter->hw, TDT, 0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1082
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1083
	/* Set the default values for the Tx Inter Packet Gap timer */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1084
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1085
	switch (adapter->hw.mac_type) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1086
	case e1000_82542_rev2_0:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1087
	case e1000_82542_rev2_1:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1088
		tipg = DEFAULT_82542_TIPG_IPGT;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1089
		tipg |= DEFAULT_82542_TIPG_IPGR1 << E1000_TIPG_IPGR1_SHIFT;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1090
		tipg |= DEFAULT_82542_TIPG_IPGR2 << E1000_TIPG_IPGR2_SHIFT;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1091
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1092
	default:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1093
		if(adapter->hw.media_type == e1000_media_type_fiber ||
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1094
		   adapter->hw.media_type == e1000_media_type_internal_serdes)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1095
			tipg = DEFAULT_82543_TIPG_IPGT_FIBER;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1096
		else
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1097
			tipg = DEFAULT_82543_TIPG_IPGT_COPPER;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1098
		tipg |= DEFAULT_82543_TIPG_IPGR1 << E1000_TIPG_IPGR1_SHIFT;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1099
		tipg |= DEFAULT_82543_TIPG_IPGR2 << E1000_TIPG_IPGR2_SHIFT;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1100
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1101
	E1000_WRITE_REG(&adapter->hw, TIPG, tipg);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1102
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1103
	/* Set the Tx Interrupt Delay register */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1104
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1105
	E1000_WRITE_REG(&adapter->hw, TIDV, adapter->tx_int_delay);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1106
	if(adapter->hw.mac_type >= e1000_82540)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1107
		E1000_WRITE_REG(&adapter->hw, TADV, adapter->tx_abs_int_delay);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1108
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1109
	/* Program the Transmit Control Register */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1110
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1111
	tctl = E1000_READ_REG(&adapter->hw, TCTL);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1112
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1113
	tctl &= ~E1000_TCTL_CT;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1114
	tctl |= E1000_TCTL_EN | E1000_TCTL_PSP |
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1115
		(E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1116
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1117
	E1000_WRITE_REG(&adapter->hw, TCTL, tctl);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1118
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1119
	e1000_config_collision_dist(&adapter->hw);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1120
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1121
	/* Setup Transmit Descriptor Settings for eop descriptor */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1122
	adapter->txd_cmd = E1000_TXD_CMD_IDE | E1000_TXD_CMD_EOP |
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1123
		E1000_TXD_CMD_IFCS;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1124
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1125
	if(adapter->hw.mac_type < e1000_82543)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1126
		adapter->txd_cmd |= E1000_TXD_CMD_RPS;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1127
	else
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1128
		adapter->txd_cmd |= E1000_TXD_CMD_RS;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1129
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1130
	/* Cache if we're 82544 running in PCI-X because we'll
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1131
	 * need this to apply a workaround later in the send path. */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1132
	if(adapter->hw.mac_type == e1000_82544 &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1133
	   adapter->hw.bus_type == e1000_bus_type_pcix)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1134
		adapter->pcix_82544 = 1;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1135
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1136
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1137
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1138
 * e1000_setup_rx_resources - allocate Rx resources (Descriptors)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1139
 * @adapter: board private structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1140
 *
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1141
 * Returns 0 on success, negative on failure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1142
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1143
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1144
int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1145
e1000_setup_rx_resources(struct e1000_adapter *adapter)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1146
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1147
	struct e1000_desc_ring *rxdr = &adapter->rx_ring;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1148
	struct pci_dev *pdev = adapter->pdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1149
	int size, desc_len;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1150
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1151
	size = sizeof(struct e1000_buffer) * rxdr->count;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1152
	rxdr->buffer_info = vmalloc(size);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1153
	if(!rxdr->buffer_info) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1154
		DPRINTK(PROBE, ERR,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1155
		"Unable to allocate memory for the receive descriptor ring\n");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1156
		return -ENOMEM;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1157
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1158
	memset(rxdr->buffer_info, 0, size);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1159
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1160
	size = sizeof(struct e1000_ps_page) * rxdr->count;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1161
	rxdr->ps_page = kmalloc(size, GFP_KERNEL);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1162
	if(!rxdr->ps_page) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1163
		vfree(rxdr->buffer_info);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1164
		DPRINTK(PROBE, ERR,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1165
		"Unable to allocate memory for the receive descriptor ring\n");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1166
		return -ENOMEM;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1167
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1168
	memset(rxdr->ps_page, 0, size);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1169
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1170
	size = sizeof(struct e1000_ps_page_dma) * rxdr->count;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1171
	rxdr->ps_page_dma = kmalloc(size, GFP_KERNEL);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1172
	if(!rxdr->ps_page_dma) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1173
		vfree(rxdr->buffer_info);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1174
		kfree(rxdr->ps_page);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1175
		DPRINTK(PROBE, ERR,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1176
		"Unable to allocate memory for the receive descriptor ring\n");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1177
		return -ENOMEM;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1178
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1179
	memset(rxdr->ps_page_dma, 0, size);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1180
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1181
	if(adapter->hw.mac_type <= e1000_82547_rev_2)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1182
		desc_len = sizeof(struct e1000_rx_desc);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1183
	else
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1184
		desc_len = sizeof(union e1000_rx_desc_packet_split);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1185
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1186
	/* Round up to nearest 4K */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1187
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1188
	rxdr->size = rxdr->count * desc_len;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1189
	E1000_ROUNDUP(rxdr->size, 4096);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1190
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1191
	rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1192
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1193
	if(!rxdr->desc) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1194
setup_rx_desc_die:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1195
		vfree(rxdr->buffer_info);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1196
		kfree(rxdr->ps_page);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1197
		kfree(rxdr->ps_page_dma);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1198
		DPRINTK(PROBE, ERR,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1199
		"Unable to allocate memory for the receive descriptor ring\n");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1200
		return -ENOMEM;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1201
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1202
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1203
	/* Fix for errata 23, can't cross 64kB boundary */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1204
	if (!e1000_check_64k_bound(adapter, rxdr->desc, rxdr->size)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1205
		void *olddesc = rxdr->desc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1206
		dma_addr_t olddma = rxdr->dma;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1207
		DPRINTK(RX_ERR, ERR, "rxdr align check failed: %u bytes "
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1208
				     "at %p\n", rxdr->size, rxdr->desc);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1209
		/* Try again, without freeing the previous */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1210
		rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1211
		if(!rxdr->desc) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1212
		/* Failed allocation, critical failure */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1213
			pci_free_consistent(pdev, rxdr->size, olddesc, olddma);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1214
			goto setup_rx_desc_die;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1215
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1216
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1217
		if (!e1000_check_64k_bound(adapter, rxdr->desc, rxdr->size)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1218
			/* give up */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1219
			pci_free_consistent(pdev, rxdr->size, rxdr->desc,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1220
					    rxdr->dma);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1221
			pci_free_consistent(pdev, rxdr->size, olddesc, olddma);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1222
			DPRINTK(PROBE, ERR,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1223
				"Unable to allocate aligned memory "
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1224
				"for the receive descriptor ring\n");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1225
			vfree(rxdr->buffer_info);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1226
			kfree(rxdr->ps_page);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1227
			kfree(rxdr->ps_page_dma);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1228
			return -ENOMEM;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1229
		} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1230
			/* Free old allocation, new allocation was successful */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1231
			pci_free_consistent(pdev, rxdr->size, olddesc, olddma);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1232
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1233
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1234
	memset(rxdr->desc, 0, rxdr->size);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1235
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1236
	rxdr->next_to_clean = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1237
	rxdr->next_to_use = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1238
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1239
	return 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1240
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1241
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1242
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1243
 * e1000_setup_rctl - configure the receive control registers
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1244
 * @adapter: Board private structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1245
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1246
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1247
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1248
e1000_setup_rctl(struct e1000_adapter *adapter)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1249
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1250
	uint32_t rctl, rfctl;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1251
	uint32_t psrctl = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1252
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1253
	rctl = E1000_READ_REG(&adapter->hw, RCTL);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1254
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1255
	rctl &= ~(3 << E1000_RCTL_MO_SHIFT);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1256
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1257
	rctl |= E1000_RCTL_EN | E1000_RCTL_BAM |
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1258
		E1000_RCTL_LBM_NO | E1000_RCTL_RDMTS_HALF |
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1259
		(adapter->hw.mc_filter_type << E1000_RCTL_MO_SHIFT);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1260
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1261
	if(adapter->hw.tbi_compatibility_on == 1)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1262
		rctl |= E1000_RCTL_SBP;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1263
	else
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1264
		rctl &= ~E1000_RCTL_SBP;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1265
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1266
	if (adapter->netdev->mtu <= ETH_DATA_LEN)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1267
		rctl &= ~E1000_RCTL_LPE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1268
	else
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1269
		rctl |= E1000_RCTL_LPE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1270
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1271
	/* Setup buffer sizes */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1272
	if(adapter->hw.mac_type == e1000_82573) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1273
		/* We can now specify buffers in 1K increments.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1274
		 * BSIZE and BSEX are ignored in this case. */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1275
		rctl |= adapter->rx_buffer_len << 0x11;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1276
	} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1277
		rctl &= ~E1000_RCTL_SZ_4096;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1278
		rctl |= E1000_RCTL_BSEX; 
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1279
		switch (adapter->rx_buffer_len) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1280
		case E1000_RXBUFFER_2048:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1281
		default:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1282
			rctl |= E1000_RCTL_SZ_2048;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1283
			rctl &= ~E1000_RCTL_BSEX;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1284
			break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1285
		case E1000_RXBUFFER_4096:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1286
			rctl |= E1000_RCTL_SZ_4096;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1287
			break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1288
		case E1000_RXBUFFER_8192:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1289
			rctl |= E1000_RCTL_SZ_8192;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1290
			break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1291
		case E1000_RXBUFFER_16384:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1292
			rctl |= E1000_RCTL_SZ_16384;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1293
			break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1294
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1295
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1296
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1297
#ifdef CONFIG_E1000_PACKET_SPLIT
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1298
	/* 82571 and greater support packet-split where the protocol
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1299
	 * header is placed in skb->data and the packet data is
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1300
	 * placed in pages hanging off of skb_shinfo(skb)->nr_frags.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1301
	 * In the case of a non-split, skb->data is linearly filled,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1302
	 * followed by the page buffers.  Therefore, skb->data is
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1303
	 * sized to hold the largest protocol header.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1304
	 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1305
	adapter->rx_ps = (adapter->hw.mac_type > e1000_82547_rev_2) 
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1306
			  && (adapter->netdev->mtu 
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1307
	                      < ((3 * PAGE_SIZE) + adapter->rx_ps_bsize0));
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1308
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1309
	if(adapter->rx_ps) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1310
		/* Configure extra packet-split registers */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1311
		rfctl = E1000_READ_REG(&adapter->hw, RFCTL);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1312
		rfctl |= E1000_RFCTL_EXTEN;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1313
		/* disable IPv6 packet split support */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1314
		rfctl |= E1000_RFCTL_IPV6_DIS;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1315
		E1000_WRITE_REG(&adapter->hw, RFCTL, rfctl);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1316
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1317
		rctl |= E1000_RCTL_DTYP_PS | E1000_RCTL_SECRC;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1318
		
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1319
		psrctl |= adapter->rx_ps_bsize0 >>
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1320
			E1000_PSRCTL_BSIZE0_SHIFT;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1321
		psrctl |= PAGE_SIZE >>
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1322
			E1000_PSRCTL_BSIZE1_SHIFT;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1323
		psrctl |= PAGE_SIZE <<
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1324
			E1000_PSRCTL_BSIZE2_SHIFT;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1325
		psrctl |= PAGE_SIZE <<
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1326
			E1000_PSRCTL_BSIZE3_SHIFT;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1327
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1328
		E1000_WRITE_REG(&adapter->hw, PSRCTL, psrctl);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1329
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1330
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1331
	E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1332
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1333
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1334
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1335
 * e1000_configure_rx - Configure 8254x Receive Unit after Reset
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1336
 * @adapter: board private structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1337
 *
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1338
 * Configure the Rx unit of the MAC after a reset.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1339
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1340
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1341
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1342
e1000_configure_rx(struct e1000_adapter *adapter)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1343
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1344
	uint64_t rdba = adapter->rx_ring.dma;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1345
	uint32_t rdlen, rctl, rxcsum;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1346
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1347
	if(adapter->rx_ps) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1348
		rdlen = adapter->rx_ring.count *
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1349
			sizeof(union e1000_rx_desc_packet_split);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1350
		adapter->clean_rx = e1000_clean_rx_irq_ps;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1351
		adapter->alloc_rx_buf = e1000_alloc_rx_buffers_ps;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1352
	} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1353
		rdlen = adapter->rx_ring.count * sizeof(struct e1000_rx_desc);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1354
		adapter->clean_rx = e1000_clean_rx_irq;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1355
		adapter->alloc_rx_buf = e1000_alloc_rx_buffers;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1356
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1357
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1358
	/* disable receives while setting up the descriptors */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1359
	rctl = E1000_READ_REG(&adapter->hw, RCTL);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1360
	E1000_WRITE_REG(&adapter->hw, RCTL, rctl & ~E1000_RCTL_EN);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1361
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1362
	/* set the Receive Delay Timer Register */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1363
	E1000_WRITE_REG(&adapter->hw, RDTR, adapter->rx_int_delay);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1364
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1365
	if(adapter->hw.mac_type >= e1000_82540) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1366
		E1000_WRITE_REG(&adapter->hw, RADV, adapter->rx_abs_int_delay);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1367
		if(adapter->itr > 1)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1368
			E1000_WRITE_REG(&adapter->hw, ITR,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1369
				1000000000 / (adapter->itr * 256));
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1370
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1371
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1372
	/* Setup the Base and Length of the Rx Descriptor Ring */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1373
	E1000_WRITE_REG(&adapter->hw, RDBAL, (rdba & 0x00000000ffffffffULL));
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1374
	E1000_WRITE_REG(&adapter->hw, RDBAH, (rdba >> 32));
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1375
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1376
	E1000_WRITE_REG(&adapter->hw, RDLEN, rdlen);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1377
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1378
	/* Setup the HW Rx Head and Tail Descriptor Pointers */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1379
	E1000_WRITE_REG(&adapter->hw, RDH, 0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1380
	E1000_WRITE_REG(&adapter->hw, RDT, 0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1381
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1382
	/* Enable 82543 Receive Checksum Offload for TCP and UDP */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1383
	if(adapter->hw.mac_type >= e1000_82543) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1384
		rxcsum = E1000_READ_REG(&adapter->hw, RXCSUM);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1385
		if(adapter->rx_csum == TRUE) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1386
			rxcsum |= E1000_RXCSUM_TUOFL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1387
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1388
			/* Enable 82573 IPv4 payload checksum for UDP fragments
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1389
			 * Must be used in conjunction with packet-split. */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1390
			if((adapter->hw.mac_type > e1000_82547_rev_2) && 
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1391
			   (adapter->rx_ps)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1392
				rxcsum |= E1000_RXCSUM_IPPCSE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1393
			}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1394
		} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1395
			rxcsum &= ~E1000_RXCSUM_TUOFL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1396
			/* don't need to clear IPPCSE as it defaults to 0 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1397
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1398
		E1000_WRITE_REG(&adapter->hw, RXCSUM, rxcsum);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1399
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1400
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1401
	if (adapter->hw.mac_type == e1000_82573)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1402
		E1000_WRITE_REG(&adapter->hw, ERT, 0x0100);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1403
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1404
	/* Enable Receives */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1405
	E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1406
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1407
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1408
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1409
 * e1000_free_tx_resources - Free Tx Resources
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1410
 * @adapter: board private structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1411
 *
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1412
 * Free all transmit software resources
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1413
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1414
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1415
void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1416
e1000_free_tx_resources(struct e1000_adapter *adapter)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1417
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1418
	struct pci_dev *pdev = adapter->pdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1419
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1420
	e1000_clean_tx_ring(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1421
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1422
	vfree(adapter->tx_ring.buffer_info);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1423
	adapter->tx_ring.buffer_info = NULL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1424
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1425
	pci_free_consistent(pdev, adapter->tx_ring.size,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1426
	                    adapter->tx_ring.desc, adapter->tx_ring.dma);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1427
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1428
	adapter->tx_ring.desc = NULL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1429
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1430
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1431
static inline void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1432
e1000_unmap_and_free_tx_resource(struct e1000_adapter *adapter,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1433
			struct e1000_buffer *buffer_info)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1434
{
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  1435
	if (adapter->ecdev)
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  1436
		return;
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  1437
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1438
	if(buffer_info->dma) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1439
		pci_unmap_page(adapter->pdev,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1440
				buffer_info->dma,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1441
				buffer_info->length,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1442
				PCI_DMA_TODEVICE);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1443
		buffer_info->dma = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1444
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1445
	if(buffer_info->skb) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1446
		dev_kfree_skb_any(buffer_info->skb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1447
		buffer_info->skb = NULL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1448
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1449
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1450
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1451
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1452
 * e1000_clean_tx_ring - Free Tx Buffers
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1453
 * @adapter: board private structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1454
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1455
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1456
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1457
e1000_clean_tx_ring(struct e1000_adapter *adapter)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1458
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1459
	struct e1000_desc_ring *tx_ring = &adapter->tx_ring;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1460
	struct e1000_buffer *buffer_info;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1461
	unsigned long size;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1462
	unsigned int i;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1463
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1464
	/* Free all the Tx ring sk_buffs */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1465
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1466
	if (likely(adapter->previous_buffer_info.skb != NULL)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1467
		e1000_unmap_and_free_tx_resource(adapter,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1468
				&adapter->previous_buffer_info);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1469
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1470
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1471
	for(i = 0; i < tx_ring->count; i++) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1472
		buffer_info = &tx_ring->buffer_info[i];
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1473
		e1000_unmap_and_free_tx_resource(adapter, buffer_info);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1474
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1475
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1476
	size = sizeof(struct e1000_buffer) * tx_ring->count;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1477
	memset(tx_ring->buffer_info, 0, size);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1478
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1479
	/* Zero out the descriptor ring */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1480
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1481
	memset(tx_ring->desc, 0, tx_ring->size);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1482
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1483
	tx_ring->next_to_use = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1484
	tx_ring->next_to_clean = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1485
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1486
	E1000_WRITE_REG(&adapter->hw, TDH, 0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1487
	E1000_WRITE_REG(&adapter->hw, TDT, 0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1488
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1489
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1490
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1491
 * e1000_free_rx_resources - Free Rx Resources
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1492
 * @adapter: board private structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1493
 *
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1494
 * Free all receive software resources
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1495
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1496
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1497
void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1498
e1000_free_rx_resources(struct e1000_adapter *adapter)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1499
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1500
	struct e1000_desc_ring *rx_ring = &adapter->rx_ring;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1501
	struct pci_dev *pdev = adapter->pdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1502
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1503
	e1000_clean_rx_ring(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1504
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1505
	vfree(rx_ring->buffer_info);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1506
	rx_ring->buffer_info = NULL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1507
	kfree(rx_ring->ps_page);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1508
	rx_ring->ps_page = NULL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1509
	kfree(rx_ring->ps_page_dma);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1510
	rx_ring->ps_page_dma = NULL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1511
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1512
	pci_free_consistent(pdev, rx_ring->size, rx_ring->desc, rx_ring->dma);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1513
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1514
	rx_ring->desc = NULL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1515
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1516
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1517
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1518
 * e1000_clean_rx_ring - Free Rx Buffers
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1519
 * @adapter: board private structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1520
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1521
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1522
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1523
e1000_clean_rx_ring(struct e1000_adapter *adapter)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1524
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1525
	struct e1000_desc_ring *rx_ring = &adapter->rx_ring;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1526
	struct e1000_buffer *buffer_info;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1527
	struct e1000_ps_page *ps_page;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1528
	struct e1000_ps_page_dma *ps_page_dma;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1529
	struct pci_dev *pdev = adapter->pdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1530
	unsigned long size;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1531
	unsigned int i, j;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1532
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1533
	/* Free all the Rx ring sk_buffs */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1534
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1535
	for(i = 0; i < rx_ring->count; i++) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1536
		buffer_info = &rx_ring->buffer_info[i];
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1537
		if(buffer_info->skb) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1538
			ps_page = &rx_ring->ps_page[i];
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1539
			ps_page_dma = &rx_ring->ps_page_dma[i];
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1540
			pci_unmap_single(pdev,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1541
					 buffer_info->dma,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1542
					 buffer_info->length,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1543
					 PCI_DMA_FROMDEVICE);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1544
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1545
			dev_kfree_skb(buffer_info->skb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1546
			buffer_info->skb = NULL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1547
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1548
			for(j = 0; j < PS_PAGE_BUFFERS; j++) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1549
				if(!ps_page->ps_page[j]) break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1550
				pci_unmap_single(pdev,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1551
						 ps_page_dma->ps_page_dma[j],
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1552
						 PAGE_SIZE, PCI_DMA_FROMDEVICE);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1553
				ps_page_dma->ps_page_dma[j] = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1554
				put_page(ps_page->ps_page[j]);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1555
				ps_page->ps_page[j] = NULL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1556
			}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1557
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1558
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1559
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1560
	size = sizeof(struct e1000_buffer) * rx_ring->count;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1561
	memset(rx_ring->buffer_info, 0, size);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1562
	size = sizeof(struct e1000_ps_page) * rx_ring->count;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1563
	memset(rx_ring->ps_page, 0, size);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1564
	size = sizeof(struct e1000_ps_page_dma) * rx_ring->count;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1565
	memset(rx_ring->ps_page_dma, 0, size);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1566
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1567
	/* Zero out the descriptor ring */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1568
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1569
	memset(rx_ring->desc, 0, rx_ring->size);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1570
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1571
	rx_ring->next_to_clean = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1572
	rx_ring->next_to_use = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1573
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1574
	E1000_WRITE_REG(&adapter->hw, RDH, 0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1575
	E1000_WRITE_REG(&adapter->hw, RDT, 0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1576
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1577
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1578
/* The 82542 2.0 (revision 2) needs to have the receive unit in reset
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1579
 * and memory write and invalidate disabled for certain operations
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1580
 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1581
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1582
e1000_enter_82542_rst(struct e1000_adapter *adapter)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1583
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1584
	struct net_device *netdev = adapter->netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1585
	uint32_t rctl;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1586
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1587
	e1000_pci_clear_mwi(&adapter->hw);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1588
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1589
	rctl = E1000_READ_REG(&adapter->hw, RCTL);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1590
	rctl |= E1000_RCTL_RST;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1591
	E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1592
	E1000_WRITE_FLUSH(&adapter->hw);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1593
	mdelay(5);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1594
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1595
	if (!adapter->ecdev && netif_running(netdev))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1596
		e1000_clean_rx_ring(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1597
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1598
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1599
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1600
e1000_leave_82542_rst(struct e1000_adapter *adapter)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1601
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1602
	struct net_device *netdev = adapter->netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1603
	uint32_t rctl;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1604
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1605
	rctl = E1000_READ_REG(&adapter->hw, RCTL);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1606
	rctl &= ~E1000_RCTL_RST;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1607
	E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1608
	E1000_WRITE_FLUSH(&adapter->hw);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1609
	mdelay(5);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1610
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1611
	if(adapter->hw.pci_cmd_word & PCI_COMMAND_INVALIDATE)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1612
		e1000_pci_set_mwi(&adapter->hw);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1613
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1614
	if (!adapter->ecdev && netif_running(netdev)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1615
		e1000_configure_rx(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1616
		e1000_alloc_rx_buffers(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1617
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1618
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1619
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1620
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1621
 * e1000_set_mac - Change the Ethernet Address of the NIC
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1622
 * @netdev: network interface device structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1623
 * @p: pointer to an address structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1624
 *
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1625
 * Returns 0 on success, negative on failure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1626
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1627
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1628
static int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1629
e1000_set_mac(struct net_device *netdev, void *p)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1630
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1631
	struct e1000_adapter *adapter = netdev_priv(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1632
	struct sockaddr *addr = p;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1633
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1634
	if(!is_valid_ether_addr(addr->sa_data))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1635
		return -EADDRNOTAVAIL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1636
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1637
	/* 82542 2.0 needs to be in reset to write receive address registers */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1638
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1639
	if(adapter->hw.mac_type == e1000_82542_rev2_0)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1640
		e1000_enter_82542_rst(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1641
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1642
	memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1643
	memcpy(adapter->hw.mac_addr, addr->sa_data, netdev->addr_len);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1644
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1645
	e1000_rar_set(&adapter->hw, adapter->hw.mac_addr, 0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1646
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1647
	if(adapter->hw.mac_type == e1000_82542_rev2_0)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1648
		e1000_leave_82542_rst(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1649
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1650
	return 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1651
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1652
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1653
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1654
 * e1000_set_multi - Multicast and Promiscuous mode set
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1655
 * @netdev: network interface device structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1656
 *
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1657
 * The set_multi entry point is called whenever the multicast address
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1658
 * list or the network interface flags are updated.  This routine is
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1659
 * responsible for configuring the hardware for proper multicast,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1660
 * promiscuous mode, and all-multi behavior.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1661
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1662
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1663
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1664
e1000_set_multi(struct net_device *netdev)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1665
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1666
	struct e1000_adapter *adapter = netdev_priv(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1667
	struct e1000_hw *hw = &adapter->hw;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1668
	struct dev_mc_list *mc_ptr;
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  1669
	unsigned long flags = 0;
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1670
	uint32_t rctl;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1671
	uint32_t hash_value;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1672
	int i;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1673
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  1674
    if (!adapter->ecdev)
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  1675
        spin_lock_irqsave(&adapter->tx_lock, flags);
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1676
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1677
	/* Check for Promiscuous and All Multicast modes */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1678
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1679
	rctl = E1000_READ_REG(hw, RCTL);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1680
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1681
	if(netdev->flags & IFF_PROMISC) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1682
		rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1683
	} else if(netdev->flags & IFF_ALLMULTI) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1684
		rctl |= E1000_RCTL_MPE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1685
		rctl &= ~E1000_RCTL_UPE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1686
	} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1687
		rctl &= ~(E1000_RCTL_UPE | E1000_RCTL_MPE);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1688
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1689
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1690
	E1000_WRITE_REG(hw, RCTL, rctl);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1691
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1692
	/* 82542 2.0 needs to be in reset to write receive address registers */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1693
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1694
	if(hw->mac_type == e1000_82542_rev2_0)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1695
		e1000_enter_82542_rst(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1696
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1697
	/* load the first 14 multicast address into the exact filters 1-14
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1698
	 * RAR 0 is used for the station MAC adddress
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1699
	 * if there are not 14 addresses, go ahead and clear the filters
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1700
	 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1701
	mc_ptr = netdev->mc_list;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1702
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1703
	for(i = 1; i < E1000_RAR_ENTRIES; i++) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1704
		if(mc_ptr) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1705
			e1000_rar_set(hw, mc_ptr->dmi_addr, i);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1706
			mc_ptr = mc_ptr->next;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1707
		} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1708
			E1000_WRITE_REG_ARRAY(hw, RA, i << 1, 0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1709
			E1000_WRITE_REG_ARRAY(hw, RA, (i << 1) + 1, 0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1710
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1711
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1712
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1713
	/* clear the old settings from the multicast hash table */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1714
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1715
	for(i = 0; i < E1000_NUM_MTA_REGISTERS; i++)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1716
		E1000_WRITE_REG_ARRAY(hw, MTA, i, 0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1717
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1718
	/* load any remaining addresses into the hash table */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1719
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1720
	for(; mc_ptr; mc_ptr = mc_ptr->next) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1721
		hash_value = e1000_hash_mc_addr(hw, mc_ptr->dmi_addr);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1722
		e1000_mta_set(hw, hash_value);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1723
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1724
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1725
	if(hw->mac_type == e1000_82542_rev2_0)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1726
		e1000_leave_82542_rst(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1727
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  1728
    if (!adapter->ecdev)
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  1729
        spin_unlock_irqrestore(&adapter->tx_lock, flags);
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1730
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1731
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1732
/* Need to wait a few seconds after link up to get diagnostic information from
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1733
 * the phy */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1734
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1735
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1736
e1000_update_phy_info(unsigned long data)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1737
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1738
	struct e1000_adapter *adapter = (struct e1000_adapter *) data;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1739
	e1000_phy_get_info(&adapter->hw, &adapter->phy_info);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1740
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1741
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1742
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1743
 * e1000_82547_tx_fifo_stall - Timer Call-back
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1744
 * @data: pointer to adapter cast into an unsigned long
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1745
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1746
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1747
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1748
e1000_82547_tx_fifo_stall(unsigned long data)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1749
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1750
	struct e1000_adapter *adapter = (struct e1000_adapter *) data;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1751
	struct net_device *netdev = adapter->netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1752
	uint32_t tctl;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1753
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1754
	if(atomic_read(&adapter->tx_fifo_stall)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1755
		if((E1000_READ_REG(&adapter->hw, TDT) ==
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1756
		    E1000_READ_REG(&adapter->hw, TDH)) &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1757
		   (E1000_READ_REG(&adapter->hw, TDFT) ==
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1758
		    E1000_READ_REG(&adapter->hw, TDFH)) &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1759
		   (E1000_READ_REG(&adapter->hw, TDFTS) ==
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1760
		    E1000_READ_REG(&adapter->hw, TDFHS))) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1761
			tctl = E1000_READ_REG(&adapter->hw, TCTL);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1762
			E1000_WRITE_REG(&adapter->hw, TCTL,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1763
					tctl & ~E1000_TCTL_EN);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1764
			E1000_WRITE_REG(&adapter->hw, TDFT,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1765
					adapter->tx_head_addr);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1766
			E1000_WRITE_REG(&adapter->hw, TDFH,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1767
					adapter->tx_head_addr);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1768
			E1000_WRITE_REG(&adapter->hw, TDFTS,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1769
					adapter->tx_head_addr);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1770
			E1000_WRITE_REG(&adapter->hw, TDFHS,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1771
					adapter->tx_head_addr);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1772
			E1000_WRITE_REG(&adapter->hw, TCTL, tctl);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1773
			E1000_WRITE_FLUSH(&adapter->hw);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1774
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1775
			adapter->tx_fifo_head = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1776
			atomic_set(&adapter->tx_fifo_stall, 0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1777
			if (!adapter->ecdev) netif_wake_queue(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1778
		} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1779
			mod_timer(&adapter->tx_fifo_stall_timer, jiffies + 1);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1780
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1781
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1782
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1783
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1784
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1785
 * e1000_watchdog - Timer Call-back
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1786
 * @data: pointer to adapter cast into an unsigned long
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1787
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1788
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1789
e1000_watchdog(unsigned long data)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1790
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1791
	struct e1000_adapter *adapter = (struct e1000_adapter *) data;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1792
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1793
	/* Do the rest outside of interrupt context */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1794
	schedule_work(&adapter->watchdog_task);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1795
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1796
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1797
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1798
e1000_watchdog_task(struct e1000_adapter *adapter)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1799
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1800
	struct net_device *netdev = adapter->netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1801
	struct e1000_desc_ring *txdr = &adapter->tx_ring;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1802
	uint32_t link;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1803
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1804
	e1000_check_for_link(&adapter->hw);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1805
	if (adapter->hw.mac_type == e1000_82573) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1806
		e1000_enable_tx_pkt_filtering(&adapter->hw);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1807
		if(adapter->mng_vlan_id != adapter->hw.mng_cookie.vlan_id)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1808
			e1000_update_mng_vlan(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1809
	}	
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1810
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1811
	if((adapter->hw.media_type == e1000_media_type_internal_serdes) &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1812
	   !(E1000_READ_REG(&adapter->hw, TXCW) & E1000_TXCW_ANE))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1813
		link = !adapter->hw.serdes_link_down;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1814
	else
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1815
		link = E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_LU;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1816
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1817
	if (link) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1818
		if ((adapter->ecdev && !ecdev_get_link(adapter->ecdev))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1819
				|| (!adapter->ecdev && !netif_carrier_ok(netdev))) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1820
			e1000_get_speed_and_duplex(&adapter->hw,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1821
			                           &adapter->link_speed,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1822
			                           &adapter->link_duplex);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1823
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1824
			DPRINTK(LINK, INFO, "NIC Link is Up %d Mbps %s\n",
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1825
			       adapter->link_speed,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1826
			       adapter->link_duplex == FULL_DUPLEX ?
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1827
			       "Full Duplex" : "Half Duplex");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1828
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1829
			if (adapter->ecdev) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1830
				ecdev_set_link(adapter->ecdev, 1);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1831
			} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1832
				netif_carrier_on(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1833
				netif_wake_queue(netdev);
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  1834
                mod_timer(&adapter->phy_info_timer, jiffies + 2 * HZ);
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1835
			}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1836
			adapter->smartspeed = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1837
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1838
	} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1839
		if ((adapter->ecdev && ecdev_get_link(adapter->ecdev))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1840
				|| (!adapter->ecdev && netif_carrier_ok(netdev))) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1841
			adapter->link_speed = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1842
			adapter->link_duplex = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1843
			DPRINTK(LINK, INFO, "NIC Link is Down\n");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1844
			if (adapter->ecdev) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1845
				ecdev_set_link(adapter->ecdev, 0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1846
			} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1847
				netif_carrier_off(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1848
				netif_stop_queue(netdev);
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  1849
                mod_timer(&adapter->phy_info_timer, jiffies + 2 * HZ);
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1850
			}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1851
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1852
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1853
		e1000_smartspeed(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1854
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1855
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1856
	e1000_update_stats(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1857
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1858
	adapter->hw.tx_packet_delta = adapter->stats.tpt - adapter->tpt_old;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1859
	adapter->tpt_old = adapter->stats.tpt;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1860
	adapter->hw.collision_delta = adapter->stats.colc - adapter->colc_old;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1861
	adapter->colc_old = adapter->stats.colc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1862
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1863
	adapter->gorcl = adapter->stats.gorcl - adapter->gorcl_old;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1864
	adapter->gorcl_old = adapter->stats.gorcl;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1865
	adapter->gotcl = adapter->stats.gotcl - adapter->gotcl_old;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1866
	adapter->gotcl_old = adapter->stats.gotcl;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1867
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1868
	e1000_update_adaptive(&adapter->hw);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1869
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  1870
	if (!adapter->ecdev && !netif_carrier_ok(netdev)) {
677
7c7cf2d6c911 Minor changes.
Florian Pose <fp@igh-essen.com>
parents: 676
diff changeset
  1871
		if(E1000_DESC_UNUSED(txdr) + 1 < txdr->count) {
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1872
			/* We've lost link, so the controller stops DMA,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1873
			 * but we've got queued Tx work that's never going
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1874
			 * to get done, so reset controller to flush Tx.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1875
			 * (Do the reset outside of interrupt context). */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1876
			schedule_work(&adapter->tx_timeout_task);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1877
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1878
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1879
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1880
	/* Dynamic mode for Interrupt Throttle Rate (ITR) */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1881
	if(adapter->hw.mac_type >= e1000_82540 && adapter->itr == 1) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1882
		/* Symmetric Tx/Rx gets a reduced ITR=2000; Total
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1883
		 * asymmetrical Tx or Rx gets ITR=8000; everyone
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1884
		 * else is between 2000-8000. */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1885
		uint32_t goc = (adapter->gotcl + adapter->gorcl) / 10000;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1886
		uint32_t dif = (adapter->gotcl > adapter->gorcl ? 
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1887
			adapter->gotcl - adapter->gorcl :
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1888
			adapter->gorcl - adapter->gotcl) / 10000;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1889
		uint32_t itr = goc > 0 ? (dif * 6000 / goc + 2000) : 8000;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1890
		E1000_WRITE_REG(&adapter->hw, ITR, 1000000000 / (itr * 256));
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1891
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1892
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1893
	/* Cause software interrupt to ensure rx ring is cleaned */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1894
	E1000_WRITE_REG(&adapter->hw, ICS, E1000_ICS_RXDMT0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1895
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1896
	/* Force detection of hung controller every watchdog period */
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  1897
	if (!adapter->ecdev) adapter->detect_tx_hung = TRUE;
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1898
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1899
	/* Reset the timer */
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  1900
	if (!adapter->ecdev)
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  1901
        mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ);
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1902
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1903
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1904
#define E1000_TX_FLAGS_CSUM		0x00000001
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1905
#define E1000_TX_FLAGS_VLAN		0x00000002
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1906
#define E1000_TX_FLAGS_TSO		0x00000004
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1907
#define E1000_TX_FLAGS_IPV4		0x00000008
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1908
#define E1000_TX_FLAGS_VLAN_MASK	0xffff0000
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1909
#define E1000_TX_FLAGS_VLAN_SHIFT	16
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1910
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1911
static inline int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1912
e1000_tso(struct e1000_adapter *adapter, struct sk_buff *skb)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1913
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1914
#ifdef NETIF_F_TSO
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1915
	struct e1000_context_desc *context_desc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1916
	unsigned int i;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1917
	uint32_t cmd_length = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1918
	uint16_t ipcse = 0, tucse, mss;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1919
	uint8_t ipcss, ipcso, tucss, tucso, hdr_len;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1920
	int err;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1921
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1922
	if(skb_shinfo(skb)->tso_size) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1923
		if (skb_header_cloned(skb)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1924
			err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1925
			if (err)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1926
				return err;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1927
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1928
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1929
		hdr_len = ((skb->h.raw - skb->data) + (skb->h.th->doff << 2));
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1930
		mss = skb_shinfo(skb)->tso_size;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1931
		if(skb->protocol == ntohs(ETH_P_IP)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1932
			skb->nh.iph->tot_len = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1933
			skb->nh.iph->check = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1934
			skb->h.th->check =
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1935
				~csum_tcpudp_magic(skb->nh.iph->saddr,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1936
						   skb->nh.iph->daddr,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1937
						   0,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1938
						   IPPROTO_TCP,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1939
						   0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1940
			cmd_length = E1000_TXD_CMD_IP;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1941
			ipcse = skb->h.raw - skb->data - 1;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1942
#ifdef NETIF_F_TSO_IPV6
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1943
		} else if(skb->protocol == ntohs(ETH_P_IPV6)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1944
			skb->nh.ipv6h->payload_len = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1945
			skb->h.th->check =
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1946
				~csum_ipv6_magic(&skb->nh.ipv6h->saddr,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1947
						 &skb->nh.ipv6h->daddr,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1948
						 0,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1949
						 IPPROTO_TCP,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1950
						 0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1951
			ipcse = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1952
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1953
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1954
		ipcss = skb->nh.raw - skb->data;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1955
		ipcso = (void *)&(skb->nh.iph->check) - (void *)skb->data;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1956
		tucss = skb->h.raw - skb->data;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1957
		tucso = (void *)&(skb->h.th->check) - (void *)skb->data;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1958
		tucse = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1959
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1960
		cmd_length |= (E1000_TXD_CMD_DEXT | E1000_TXD_CMD_TSE |
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1961
			       E1000_TXD_CMD_TCP | (skb->len - (hdr_len)));
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1962
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1963
		i = adapter->tx_ring.next_to_use;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1964
		context_desc = E1000_CONTEXT_DESC(adapter->tx_ring, i);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1965
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1966
		context_desc->lower_setup.ip_fields.ipcss  = ipcss;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1967
		context_desc->lower_setup.ip_fields.ipcso  = ipcso;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1968
		context_desc->lower_setup.ip_fields.ipcse  = cpu_to_le16(ipcse);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1969
		context_desc->upper_setup.tcp_fields.tucss = tucss;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1970
		context_desc->upper_setup.tcp_fields.tucso = tucso;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1971
		context_desc->upper_setup.tcp_fields.tucse = cpu_to_le16(tucse);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1972
		context_desc->tcp_seg_setup.fields.mss     = cpu_to_le16(mss);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1973
		context_desc->tcp_seg_setup.fields.hdr_len = hdr_len;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1974
		context_desc->cmd_and_length = cpu_to_le32(cmd_length);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1975
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1976
		if(++i == adapter->tx_ring.count) i = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1977
		adapter->tx_ring.next_to_use = i;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1978
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1979
		return 1;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1980
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1981
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1982
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1983
	return 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1984
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1985
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1986
static inline boolean_t
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1987
e1000_tx_csum(struct e1000_adapter *adapter, struct sk_buff *skb)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1988
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1989
	struct e1000_context_desc *context_desc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1990
	unsigned int i;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1991
	uint8_t css;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1992
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1993
	if(likely(skb->ip_summed == CHECKSUM_HW)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1994
		css = skb->h.raw - skb->data;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1995
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1996
		i = adapter->tx_ring.next_to_use;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1997
		context_desc = E1000_CONTEXT_DESC(adapter->tx_ring, i);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1998
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1999
		context_desc->upper_setup.tcp_fields.tucss = css;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2000
		context_desc->upper_setup.tcp_fields.tucso = css + skb->csum;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2001
		context_desc->upper_setup.tcp_fields.tucse = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2002
		context_desc->tcp_seg_setup.data = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2003
		context_desc->cmd_and_length = cpu_to_le32(E1000_TXD_CMD_DEXT);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2004
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2005
		if(unlikely(++i == adapter->tx_ring.count)) i = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2006
		adapter->tx_ring.next_to_use = i;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2007
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2008
		return TRUE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2009
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2010
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2011
	return FALSE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2012
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2013
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2014
#define E1000_MAX_TXD_PWR	12
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2015
#define E1000_MAX_DATA_PER_TXD	(1<<E1000_MAX_TXD_PWR)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2016
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2017
static inline int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2018
e1000_tx_map(struct e1000_adapter *adapter, struct sk_buff *skb,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2019
	unsigned int first, unsigned int max_per_txd,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2020
	unsigned int nr_frags, unsigned int mss)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2021
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2022
	struct e1000_desc_ring *tx_ring = &adapter->tx_ring;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2023
	struct e1000_buffer *buffer_info;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2024
	unsigned int len = skb->len;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2025
	unsigned int offset = 0, size, count = 0, i;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2026
	unsigned int f;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2027
	len -= skb->data_len;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2028
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2029
	i = tx_ring->next_to_use;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2030
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2031
	while(len) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2032
		buffer_info = &tx_ring->buffer_info[i];
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2033
		size = min(len, max_per_txd);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2034
#ifdef NETIF_F_TSO
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2035
		/* Workaround for premature desc write-backs
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2036
		 * in TSO mode.  Append 4-byte sentinel desc */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2037
		if(unlikely(mss && !nr_frags && size == len && size > 8))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2038
			size -= 4;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2039
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2040
		/* work-around for errata 10 and it applies
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2041
		 * to all controllers in PCI-X mode
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2042
		 * The fix is to make sure that the first descriptor of a
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2043
		 * packet is smaller than 2048 - 16 - 16 (or 2016) bytes
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2044
		 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2045
		if(unlikely((adapter->hw.bus_type == e1000_bus_type_pcix) &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2046
		                (size > 2015) && count == 0))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2047
		        size = 2015;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2048
                                                                                
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2049
		/* Workaround for potential 82544 hang in PCI-X.  Avoid
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2050
		 * terminating buffers within evenly-aligned dwords. */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2051
		if(unlikely(adapter->pcix_82544 &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2052
		   !((unsigned long)(skb->data + offset + size - 1) & 4) &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2053
		   size > 4))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2054
			size -= 4;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2055
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2056
		buffer_info->length = size;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2057
		buffer_info->dma =
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2058
			pci_map_single(adapter->pdev,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2059
				skb->data + offset,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2060
				size,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2061
				PCI_DMA_TODEVICE);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2062
		buffer_info->time_stamp = jiffies;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2063
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2064
		len -= size;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2065
		offset += size;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2066
		count++;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2067
		if(unlikely(++i == tx_ring->count)) i = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2068
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2069
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2070
	for(f = 0; f < nr_frags; f++) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2071
		struct skb_frag_struct *frag;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2072
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2073
		frag = &skb_shinfo(skb)->frags[f];
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2074
		len = frag->size;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2075
		offset = frag->page_offset;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2076
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2077
		while(len) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2078
			buffer_info = &tx_ring->buffer_info[i];
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2079
			size = min(len, max_per_txd);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2080
#ifdef NETIF_F_TSO
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2081
			/* Workaround for premature desc write-backs
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2082
			 * in TSO mode.  Append 4-byte sentinel desc */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2083
			if(unlikely(mss && f == (nr_frags-1) && size == len && size > 8))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2084
				size -= 4;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2085
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2086
			/* Workaround for potential 82544 hang in PCI-X.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2087
			 * Avoid terminating buffers within evenly-aligned
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2088
			 * dwords. */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2089
			if(unlikely(adapter->pcix_82544 &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2090
			   !((unsigned long)(frag->page+offset+size-1) & 4) &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2091
			   size > 4))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2092
				size -= 4;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2093
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2094
			buffer_info->length = size;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2095
			buffer_info->dma =
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2096
				pci_map_page(adapter->pdev,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2097
					frag->page,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2098
					offset,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2099
					size,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2100
					PCI_DMA_TODEVICE);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2101
			buffer_info->time_stamp = jiffies;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2102
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2103
			len -= size;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2104
			offset += size;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2105
			count++;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2106
			if(unlikely(++i == tx_ring->count)) i = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2107
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2108
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2109
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2110
	i = (i == 0) ? tx_ring->count - 1 : i - 1;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2111
	tx_ring->buffer_info[i].skb = skb;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2112
	tx_ring->buffer_info[first].next_to_watch = i;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2113
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2114
	return count;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2115
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2116
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2117
static inline void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2118
e1000_tx_queue(struct e1000_adapter *adapter, int count, int tx_flags)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2119
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2120
	struct e1000_desc_ring *tx_ring = &adapter->tx_ring;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2121
	struct e1000_tx_desc *tx_desc = NULL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2122
	struct e1000_buffer *buffer_info;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2123
	uint32_t txd_upper = 0, txd_lower = E1000_TXD_CMD_IFCS;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2124
	unsigned int i;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2125
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2126
	if(likely(tx_flags & E1000_TX_FLAGS_TSO)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2127
		txd_lower |= E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D |
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2128
		             E1000_TXD_CMD_TSE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2129
		txd_upper |= E1000_TXD_POPTS_TXSM << 8;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2130
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2131
		if(likely(tx_flags & E1000_TX_FLAGS_IPV4))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2132
			txd_upper |= E1000_TXD_POPTS_IXSM << 8;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2133
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2134
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2135
	if(likely(tx_flags & E1000_TX_FLAGS_CSUM)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2136
		txd_lower |= E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2137
		txd_upper |= E1000_TXD_POPTS_TXSM << 8;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2138
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2139
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2140
	if(unlikely(tx_flags & E1000_TX_FLAGS_VLAN)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2141
		txd_lower |= E1000_TXD_CMD_VLE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2142
		txd_upper |= (tx_flags & E1000_TX_FLAGS_VLAN_MASK);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2143
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2144
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2145
	i = tx_ring->next_to_use;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2146
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2147
	while(count--) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2148
		buffer_info = &tx_ring->buffer_info[i];
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2149
		tx_desc = E1000_TX_DESC(*tx_ring, i);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2150
		tx_desc->buffer_addr = cpu_to_le64(buffer_info->dma);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2151
		tx_desc->lower.data =
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2152
			cpu_to_le32(txd_lower | buffer_info->length);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2153
		tx_desc->upper.data = cpu_to_le32(txd_upper);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2154
		if(unlikely(++i == tx_ring->count)) i = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2155
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2156
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2157
	tx_desc->lower.data |= cpu_to_le32(adapter->txd_cmd);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2158
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2159
	/* Force memory writes to complete before letting h/w
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2160
	 * know there are new descriptors to fetch.  (Only
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2161
	 * applicable for weak-ordered memory model archs,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2162
	 * such as IA-64). */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2163
	wmb();
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2164
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2165
	tx_ring->next_to_use = i;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2166
	E1000_WRITE_REG(&adapter->hw, TDT, i);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2167
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2168
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2169
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2170
 * 82547 workaround to avoid controller hang in half-duplex environment.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2171
 * The workaround is to avoid queuing a large packet that would span
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2172
 * the internal Tx FIFO ring boundary by notifying the stack to resend
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2173
 * the packet at a later time.  This gives the Tx FIFO an opportunity to
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2174
 * flush all packets.  When that occurs, we reset the Tx FIFO pointers
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2175
 * to the beginning of the Tx FIFO.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2176
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2177
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2178
#define E1000_FIFO_HDR			0x10
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2179
#define E1000_82547_PAD_LEN		0x3E0
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2180
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2181
static inline int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2182
e1000_82547_fifo_workaround(struct e1000_adapter *adapter, struct sk_buff *skb)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2183
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2184
	uint32_t fifo_space = adapter->tx_fifo_size - adapter->tx_fifo_head;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2185
	uint32_t skb_fifo_len = skb->len + E1000_FIFO_HDR;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2186
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2187
	E1000_ROUNDUP(skb_fifo_len, E1000_FIFO_HDR);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2188
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2189
	if(adapter->link_duplex != HALF_DUPLEX)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2190
		goto no_fifo_stall_required;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2191
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2192
	if(atomic_read(&adapter->tx_fifo_stall))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2193
		return 1;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2194
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2195
	if(skb_fifo_len >= (E1000_82547_PAD_LEN + fifo_space)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2196
		atomic_set(&adapter->tx_fifo_stall, 1);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2197
		return 1;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2198
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2199
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2200
no_fifo_stall_required:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2201
	adapter->tx_fifo_head += skb_fifo_len;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2202
	if(adapter->tx_fifo_head >= adapter->tx_fifo_size)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2203
		adapter->tx_fifo_head -= adapter->tx_fifo_size;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2204
	return 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2205
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2206
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2207
#define MINIMUM_DHCP_PACKET_SIZE 282
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2208
static inline int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2209
e1000_transfer_dhcp_info(struct e1000_adapter *adapter, struct sk_buff *skb)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2210
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2211
	struct e1000_hw *hw =  &adapter->hw;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2212
	uint16_t length, offset;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2213
	if(vlan_tx_tag_present(skb)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2214
		if(!((vlan_tx_tag_get(skb) == adapter->hw.mng_cookie.vlan_id) &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2215
			( adapter->hw.mng_cookie.status &
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2216
			  E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) )
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2217
			return 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2218
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2219
	if(htons(ETH_P_IP) == skb->protocol) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2220
		const struct iphdr *ip = skb->nh.iph;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2221
		if(IPPROTO_UDP == ip->protocol) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2222
			struct udphdr *udp = (struct udphdr *)(skb->h.uh);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2223
			if(ntohs(udp->dest) == 67) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2224
				offset = (uint8_t *)udp + 8 - skb->data;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2225
				length = skb->len - offset;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2226
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2227
				return e1000_mng_write_dhcp_info(hw,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2228
						(uint8_t *)udp + 8, length);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2229
			}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2230
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2231
	} else if((skb->len > MINIMUM_DHCP_PACKET_SIZE) && (!skb->protocol)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2232
		struct ethhdr *eth = (struct ethhdr *) skb->data;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2233
		if((htons(ETH_P_IP) == eth->h_proto)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2234
			const struct iphdr *ip = 
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2235
				(struct iphdr *)((uint8_t *)skb->data+14);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2236
			if(IPPROTO_UDP == ip->protocol) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2237
				struct udphdr *udp = 
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2238
					(struct udphdr *)((uint8_t *)ip + 
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2239
						(ip->ihl << 2));
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2240
				if(ntohs(udp->dest) == 67) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2241
					offset = (uint8_t *)udp + 8 - skb->data;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2242
					length = skb->len - offset;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2243
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2244
					return e1000_mng_write_dhcp_info(hw,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2245
							(uint8_t *)udp + 8, 
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2246
							length);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2247
				}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2248
			}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2249
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2250
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2251
	return 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2252
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2253
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2254
#define TXD_USE_COUNT(S, X) (((S) >> (X)) + 1 )
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2255
static int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2256
e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2257
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2258
	struct e1000_adapter *adapter = netdev_priv(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2259
	unsigned int first, max_per_txd = E1000_MAX_DATA_PER_TXD;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2260
	unsigned int max_txd_pwr = E1000_MAX_TXD_PWR;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2261
	unsigned int tx_flags = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2262
	unsigned int len = skb->len;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2263
	unsigned long flags = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2264
	unsigned int nr_frags = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2265
	unsigned int mss = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2266
	int count = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2267
	int tso;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2268
	unsigned int f;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2269
	len -= skb->data_len;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2270
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2271
	if(unlikely(skb->len <= 0)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2272
		if (!adapter->ecdev)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2273
			dev_kfree_skb_any(skb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2274
		return NETDEV_TX_OK;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2275
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2276
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2277
#ifdef NETIF_F_TSO
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2278
	mss = skb_shinfo(skb)->tso_size;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2279
	/* The controller does a simple calculation to 
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2280
	 * make sure there is enough room in the FIFO before
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2281
	 * initiating the DMA for each buffer.  The calc is:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2282
	 * 4 = ceil(buffer len/mss).  To make sure we don't
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2283
	 * overrun the FIFO, adjust the max buffer len if mss
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2284
	 * drops. */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2285
	if(mss) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2286
		max_per_txd = min(mss << 2, max_per_txd);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2287
		max_txd_pwr = fls(max_per_txd) - 1;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2288
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2289
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2290
	if((mss) || (skb->ip_summed == CHECKSUM_HW))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2291
		count++;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2292
	count++;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2293
#else
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2294
	if(skb->ip_summed == CHECKSUM_HW)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2295
		count++;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2296
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2297
	count += TXD_USE_COUNT(len, max_txd_pwr);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2298
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2299
	if(adapter->pcix_82544)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2300
		count++;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2301
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2302
	/* work-around for errata 10 and it applies to all controllers 
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2303
	 * in PCI-X mode, so add one more descriptor to the count
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2304
	 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2305
	if(unlikely((adapter->hw.bus_type == e1000_bus_type_pcix) &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2306
			(len > 2015)))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2307
		count++;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2308
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2309
	nr_frags = skb_shinfo(skb)->nr_frags;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2310
	for(f = 0; f < nr_frags; f++)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2311
		count += TXD_USE_COUNT(skb_shinfo(skb)->frags[f].size,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2312
				       max_txd_pwr);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2313
	if(adapter->pcix_82544)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2314
		count += nr_frags;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2315
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2316
	if (!adapter->ecdev) {
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2317
		local_irq_save(flags); 
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2318
		if (!spin_trylock(&adapter->tx_lock)) { 
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2319
			/* Collision - tell upper layer to requeue */ 
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2320
			local_irq_restore(flags); 
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2321
			return NETDEV_TX_LOCKED; 
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2322
		} 
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2323
		if(adapter->hw.tx_pkt_filtering && (adapter->hw.mac_type == e1000_82573) )
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2324
			e1000_transfer_dhcp_info(adapter, skb);
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2325
	}
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2326
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2327
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2328
	/* need: count + 2 desc gap to keep tail from touching
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2329
	 * head, otherwise try next time */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2330
	if(unlikely(E1000_DESC_UNUSED(&adapter->tx_ring) < count + 2)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2331
		if (!adapter->ecdev) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2332
			netif_stop_queue(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2333
			spin_unlock_irqrestore(&adapter->tx_lock, flags);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2334
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2335
		return NETDEV_TX_BUSY;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2336
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2337
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2338
	if(unlikely(adapter->hw.mac_type == e1000_82547)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2339
		if(unlikely(e1000_82547_fifo_workaround(adapter, skb))) {
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2340
			if (!adapter->ecdev) {
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2341
				netif_stop_queue(netdev);
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2342
                mod_timer(&adapter->tx_fifo_stall_timer, jiffies);
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2343
				spin_unlock_irqrestore(&adapter->tx_lock, flags);
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2344
            }
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2345
			return NETDEV_TX_BUSY;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2346
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2347
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2348
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2349
	if(unlikely(adapter->vlgrp && vlan_tx_tag_present(skb))) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2350
		tx_flags |= E1000_TX_FLAGS_VLAN;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2351
		tx_flags |= (vlan_tx_tag_get(skb) << E1000_TX_FLAGS_VLAN_SHIFT);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2352
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2353
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2354
	first = adapter->tx_ring.next_to_use;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2355
	
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2356
	tso = e1000_tso(adapter, skb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2357
	if (tso < 0) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2358
		if (!adapter->ecdev) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2359
			dev_kfree_skb_any(skb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2360
			spin_unlock_irqrestore(&adapter->tx_lock, flags);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2361
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2362
		return NETDEV_TX_OK;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2363
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2364
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2365
	if (likely(tso))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2366
		tx_flags |= E1000_TX_FLAGS_TSO;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2367
	else if(likely(e1000_tx_csum(adapter, skb)))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2368
		tx_flags |= E1000_TX_FLAGS_CSUM;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2369
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2370
	/* Old method was to assume IPv4 packet by default if TSO was enabled.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2371
	 * 82573 hardware supports TSO capabilities for IPv6 as well...
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2372
	 * no longer assume, we must. */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2373
	if(likely(skb->protocol == ntohs(ETH_P_IP)))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2374
		tx_flags |= E1000_TX_FLAGS_IPV4;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2375
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2376
	e1000_tx_queue(adapter,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2377
		e1000_tx_map(adapter, skb, first, max_per_txd, nr_frags, mss),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2378
		tx_flags);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2379
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2380
	netdev->trans_start = jiffies;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2381
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2382
	/* Make sure there is space in the ring for the next send. */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2383
	if (!adapter->ecdev) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2384
		if(unlikely(E1000_DESC_UNUSED(&adapter->tx_ring) < MAX_SKB_FRAGS + 2))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2385
			netif_stop_queue(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2386
		spin_unlock_irqrestore(&adapter->tx_lock, flags);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2387
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2388
	return NETDEV_TX_OK;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2389
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2390
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2391
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2392
 * e1000_tx_timeout - Respond to a Tx Hang
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2393
 * @netdev: network interface device structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2394
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2395
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2396
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2397
e1000_tx_timeout(struct net_device *netdev)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2398
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2399
	struct e1000_adapter *adapter = netdev_priv(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2400
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2401
	/* Do the reset outside of interrupt context */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2402
	schedule_work(&adapter->tx_timeout_task);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2403
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2404
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2405
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2406
e1000_tx_timeout_task(struct net_device *netdev)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2407
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2408
	struct e1000_adapter *adapter = netdev_priv(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2409
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2410
	e1000_down(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2411
	e1000_up(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2412
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2413
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2414
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2415
 * e1000_get_stats - Get System Network Statistics
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2416
 * @netdev: network interface device structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2417
 *
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2418
 * Returns the address of the device statistics structure.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2419
 * The statistics are actually updated from the timer callback.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2420
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2421
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2422
static struct net_device_stats *
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2423
e1000_get_stats(struct net_device *netdev)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2424
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2425
	struct e1000_adapter *adapter = netdev_priv(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2426
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2427
	e1000_update_stats(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2428
	return &adapter->net_stats;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2429
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2430
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2431
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2432
 * e1000_change_mtu - Change the Maximum Transfer Unit
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2433
 * @netdev: network interface device structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2434
 * @new_mtu: new value for maximum frame size
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2435
 *
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2436
 * Returns 0 on success, negative on failure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2437
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2438
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2439
static int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2440
e1000_change_mtu(struct net_device *netdev, int new_mtu)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2441
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2442
	struct e1000_adapter *adapter = netdev_priv(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2443
	int max_frame = new_mtu + ENET_HEADER_SIZE + ETHERNET_FCS_SIZE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2444
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2445
	if((max_frame < MINIMUM_ETHERNET_FRAME_SIZE) ||
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2446
		(max_frame > MAX_JUMBO_FRAME_SIZE)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2447
			DPRINTK(PROBE, ERR, "Invalid MTU setting\n");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2448
			return -EINVAL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2449
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2450
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2451
#define MAX_STD_JUMBO_FRAME_SIZE 9216
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2452
	/* might want this to be bigger enum check... */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2453
	if (adapter->hw.mac_type == e1000_82573 &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2454
	    max_frame > MAXIMUM_ETHERNET_FRAME_SIZE) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2455
		DPRINTK(PROBE, ERR, "Jumbo Frames not supported "
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2456
				    "on 82573\n");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2457
		return -EINVAL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2458
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2459
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2460
	if(adapter->hw.mac_type > e1000_82547_rev_2) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2461
		adapter->rx_buffer_len = max_frame;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2462
		E1000_ROUNDUP(adapter->rx_buffer_len, 1024);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2463
	} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2464
		if(unlikely((adapter->hw.mac_type < e1000_82543) &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2465
		   (max_frame > MAXIMUM_ETHERNET_FRAME_SIZE))) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2466
			DPRINTK(PROBE, ERR, "Jumbo Frames not supported "
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2467
					    "on 82542\n");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2468
			return -EINVAL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2469
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2470
		} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2471
			if(max_frame <= E1000_RXBUFFER_2048) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2472
				adapter->rx_buffer_len = E1000_RXBUFFER_2048;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2473
			} else if(max_frame <= E1000_RXBUFFER_4096) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2474
				adapter->rx_buffer_len = E1000_RXBUFFER_4096;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2475
			} else if(max_frame <= E1000_RXBUFFER_8192) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2476
				adapter->rx_buffer_len = E1000_RXBUFFER_8192;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2477
			} else if(max_frame <= E1000_RXBUFFER_16384) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2478
				adapter->rx_buffer_len = E1000_RXBUFFER_16384;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2479
			}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2480
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2481
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2482
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2483
	netdev->mtu = new_mtu;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2484
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2485
	if (adapter->ecdev || netif_running(netdev)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2486
		e1000_down(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2487
		e1000_up(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2488
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2489
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2490
	adapter->hw.max_frame_size = max_frame;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2491
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2492
	return 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2493
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2494
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2495
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2496
 * e1000_update_stats - Update the board statistics counters
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2497
 * @adapter: board private structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2498
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2499
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2500
void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2501
e1000_update_stats(struct e1000_adapter *adapter)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2502
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2503
	struct e1000_hw *hw = &adapter->hw;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2504
	unsigned long flags = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2505
	uint16_t phy_tmp;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2506
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2507
#define PHY_IDLE_ERROR_COUNT_MASK 0x00FF
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2508
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2509
	if (!adapter->ecdev)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2510
		spin_lock_irqsave(&adapter->stats_lock, flags);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2511
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2512
	/* these counters are modified from e1000_adjust_tbi_stats,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2513
	 * called from the interrupt context, so they must only
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2514
	 * be written while holding adapter->stats_lock
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2515
	 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2516
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2517
	adapter->stats.crcerrs += E1000_READ_REG(hw, CRCERRS);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2518
	adapter->stats.gprc += E1000_READ_REG(hw, GPRC);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2519
	adapter->stats.gorcl += E1000_READ_REG(hw, GORCL);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2520
	adapter->stats.gorch += E1000_READ_REG(hw, GORCH);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2521
	adapter->stats.bprc += E1000_READ_REG(hw, BPRC);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2522
	adapter->stats.mprc += E1000_READ_REG(hw, MPRC);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2523
	adapter->stats.roc += E1000_READ_REG(hw, ROC);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2524
	adapter->stats.prc64 += E1000_READ_REG(hw, PRC64);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2525
	adapter->stats.prc127 += E1000_READ_REG(hw, PRC127);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2526
	adapter->stats.prc255 += E1000_READ_REG(hw, PRC255);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2527
	adapter->stats.prc511 += E1000_READ_REG(hw, PRC511);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2528
	adapter->stats.prc1023 += E1000_READ_REG(hw, PRC1023);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2529
	adapter->stats.prc1522 += E1000_READ_REG(hw, PRC1522);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2530
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2531
	adapter->stats.symerrs += E1000_READ_REG(hw, SYMERRS);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2532
	adapter->stats.mpc += E1000_READ_REG(hw, MPC);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2533
	adapter->stats.scc += E1000_READ_REG(hw, SCC);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2534
	adapter->stats.ecol += E1000_READ_REG(hw, ECOL);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2535
	adapter->stats.mcc += E1000_READ_REG(hw, MCC);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2536
	adapter->stats.latecol += E1000_READ_REG(hw, LATECOL);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2537
	adapter->stats.dc += E1000_READ_REG(hw, DC);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2538
	adapter->stats.sec += E1000_READ_REG(hw, SEC);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2539
	adapter->stats.rlec += E1000_READ_REG(hw, RLEC);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2540
	adapter->stats.xonrxc += E1000_READ_REG(hw, XONRXC);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2541
	adapter->stats.xontxc += E1000_READ_REG(hw, XONTXC);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2542
	adapter->stats.xoffrxc += E1000_READ_REG(hw, XOFFRXC);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2543
	adapter->stats.xofftxc += E1000_READ_REG(hw, XOFFTXC);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2544
	adapter->stats.fcruc += E1000_READ_REG(hw, FCRUC);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2545
	adapter->stats.gptc += E1000_READ_REG(hw, GPTC);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2546
	adapter->stats.gotcl += E1000_READ_REG(hw, GOTCL);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2547
	adapter->stats.gotch += E1000_READ_REG(hw, GOTCH);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2548
	adapter->stats.rnbc += E1000_READ_REG(hw, RNBC);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2549
	adapter->stats.ruc += E1000_READ_REG(hw, RUC);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2550
	adapter->stats.rfc += E1000_READ_REG(hw, RFC);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2551
	adapter->stats.rjc += E1000_READ_REG(hw, RJC);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2552
	adapter->stats.torl += E1000_READ_REG(hw, TORL);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2553
	adapter->stats.torh += E1000_READ_REG(hw, TORH);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2554
	adapter->stats.totl += E1000_READ_REG(hw, TOTL);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2555
	adapter->stats.toth += E1000_READ_REG(hw, TOTH);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2556
	adapter->stats.tpr += E1000_READ_REG(hw, TPR);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2557
	adapter->stats.ptc64 += E1000_READ_REG(hw, PTC64);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2558
	adapter->stats.ptc127 += E1000_READ_REG(hw, PTC127);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2559
	adapter->stats.ptc255 += E1000_READ_REG(hw, PTC255);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2560
	adapter->stats.ptc511 += E1000_READ_REG(hw, PTC511);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2561
	adapter->stats.ptc1023 += E1000_READ_REG(hw, PTC1023);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2562
	adapter->stats.ptc1522 += E1000_READ_REG(hw, PTC1522);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2563
	adapter->stats.mptc += E1000_READ_REG(hw, MPTC);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2564
	adapter->stats.bptc += E1000_READ_REG(hw, BPTC);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2565
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2566
	/* used for adaptive IFS */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2567
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2568
	hw->tx_packet_delta = E1000_READ_REG(hw, TPT);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2569
	adapter->stats.tpt += hw->tx_packet_delta;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2570
	hw->collision_delta = E1000_READ_REG(hw, COLC);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2571
	adapter->stats.colc += hw->collision_delta;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2572
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2573
	if(hw->mac_type >= e1000_82543) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2574
		adapter->stats.algnerrc += E1000_READ_REG(hw, ALGNERRC);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2575
		adapter->stats.rxerrc += E1000_READ_REG(hw, RXERRC);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2576
		adapter->stats.tncrs += E1000_READ_REG(hw, TNCRS);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2577
		adapter->stats.cexterr += E1000_READ_REG(hw, CEXTERR);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2578
		adapter->stats.tsctc += E1000_READ_REG(hw, TSCTC);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2579
		adapter->stats.tsctfc += E1000_READ_REG(hw, TSCTFC);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2580
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2581
	if(hw->mac_type > e1000_82547_rev_2) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2582
		adapter->stats.iac += E1000_READ_REG(hw, IAC);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2583
		adapter->stats.icrxoc += E1000_READ_REG(hw, ICRXOC);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2584
		adapter->stats.icrxptc += E1000_READ_REG(hw, ICRXPTC);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2585
		adapter->stats.icrxatc += E1000_READ_REG(hw, ICRXATC);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2586
		adapter->stats.ictxptc += E1000_READ_REG(hw, ICTXPTC);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2587
		adapter->stats.ictxatc += E1000_READ_REG(hw, ICTXATC);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2588
		adapter->stats.ictxqec += E1000_READ_REG(hw, ICTXQEC);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2589
		adapter->stats.ictxqmtc += E1000_READ_REG(hw, ICTXQMTC);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2590
		adapter->stats.icrxdmtc += E1000_READ_REG(hw, ICRXDMTC);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2591
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2592
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2593
	/* Fill out the OS statistics structure */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2594
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2595
	adapter->net_stats.rx_packets = adapter->stats.gprc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2596
	adapter->net_stats.tx_packets = adapter->stats.gptc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2597
	adapter->net_stats.rx_bytes = adapter->stats.gorcl;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2598
	adapter->net_stats.tx_bytes = adapter->stats.gotcl;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2599
	adapter->net_stats.multicast = adapter->stats.mprc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2600
	adapter->net_stats.collisions = adapter->stats.colc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2601
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2602
	/* Rx Errors */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2603
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2604
	adapter->net_stats.rx_errors = adapter->stats.rxerrc +
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2605
		adapter->stats.crcerrs + adapter->stats.algnerrc +
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2606
		adapter->stats.rlec + adapter->stats.mpc + 
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2607
		adapter->stats.cexterr;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2608
	adapter->net_stats.rx_dropped = adapter->stats.mpc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2609
	adapter->net_stats.rx_length_errors = adapter->stats.rlec;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2610
	adapter->net_stats.rx_crc_errors = adapter->stats.crcerrs;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2611
	adapter->net_stats.rx_frame_errors = adapter->stats.algnerrc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2612
	adapter->net_stats.rx_fifo_errors = adapter->stats.mpc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2613
	adapter->net_stats.rx_missed_errors = adapter->stats.mpc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2614
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2615
	/* Tx Errors */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2616
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2617
	adapter->net_stats.tx_errors = adapter->stats.ecol +
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2618
	                               adapter->stats.latecol;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2619
	adapter->net_stats.tx_aborted_errors = adapter->stats.ecol;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2620
	adapter->net_stats.tx_window_errors = adapter->stats.latecol;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2621
	adapter->net_stats.tx_carrier_errors = adapter->stats.tncrs;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2622
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2623
	/* Tx Dropped needs to be maintained elsewhere */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2624
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2625
	/* Phy Stats */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2626
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2627
	if(hw->media_type == e1000_media_type_copper) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2628
		if((adapter->link_speed == SPEED_1000) &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2629
		   (!e1000_read_phy_reg(hw, PHY_1000T_STATUS, &phy_tmp))) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2630
			phy_tmp &= PHY_IDLE_ERROR_COUNT_MASK;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2631
			adapter->phy_stats.idle_errors += phy_tmp;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2632
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2633
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2634
		if((hw->mac_type <= e1000_82546) &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2635
		   (hw->phy_type == e1000_phy_m88) &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2636
		   !e1000_read_phy_reg(hw, M88E1000_RX_ERR_CNTR, &phy_tmp))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2637
			adapter->phy_stats.receive_errors += phy_tmp;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2638
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2639
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2640
	if (!adapter->ecdev)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2641
		spin_unlock_irqrestore(&adapter->stats_lock, flags);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2642
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2643
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2644
void ec_poll(struct net_device *netdev)
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2645
{
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2646
    struct e1000_adapter *adapter = netdev_priv(netdev);
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2647
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2648
    if (jiffies - adapter->ec_watchdog_jiffies >= 2 * HZ) {
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2649
        e1000_watchdog_task(adapter);
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2650
        adapter->ec_watchdog_jiffies = jiffies;
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2651
    }
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2652
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2653
    e1000_intr(0, netdev, NULL);
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2654
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2655
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2656
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2657
 * e1000_intr - Interrupt Handler
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2658
 * @irq: interrupt number
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2659
 * @data: pointer to a network interface device structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2660
 * @pt_regs: CPU registers structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2661
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2662
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2663
static irqreturn_t
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2664
e1000_intr(int irq, void *data, struct pt_regs *regs)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2665
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2666
	struct net_device *netdev = data;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2667
	struct e1000_adapter *adapter = netdev_priv(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2668
	struct e1000_hw *hw = &adapter->hw;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2669
	uint32_t icr = E1000_READ_REG(hw, ICR);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2670
#ifndef CONFIG_E1000_NAPI
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2671
	unsigned int i;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2672
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2674
	if(unlikely(!icr))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2675
		return IRQ_NONE;  /* Not our interrupt */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2676
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2677
	if(unlikely(icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC))) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2678
		hw->get_link_status = 1;
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2679
		if (!adapter->ecdev)
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2680
            mod_timer(&adapter->watchdog_timer, jiffies);
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2681
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2682
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2683
#ifdef CONFIG_E1000_NAPI
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2684
	if(!adapter->ecdev && likely(netif_rx_schedule_prep(netdev))) {
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2685
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2686
		/* Disable interrupts and register for poll. The flush 
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2687
		  of the posted write is intentionally left out.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2688
		*/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2689
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2690
		atomic_inc(&adapter->irq_sem);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2691
		E1000_WRITE_REG(hw, IMC, ~0);
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2692
		__netif_rx_schedule(netdev);
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2693
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2694
#else
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2695
	/* Writing IMC and IMS is needed for 82547.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2696
	   Due to Hub Link bus being occupied, an interrupt
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2697
	   de-assertion message is not able to be sent.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2698
	   When an interrupt assertion message is generated later,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2699
	   two messages are re-ordered and sent out.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2700
	   That causes APIC to think 82547 is in de-assertion
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2701
	   state, while 82547 is in assertion state, resulting
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2702
	   in dead lock. Writing IMC forces 82547 into
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2703
	   de-assertion state.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2704
	*/
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2705
	if(!adapter->ecdev &&
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2706
			(hw->mac_type == e1000_82547 || hw->mac_type == e1000_82547_rev_2)){
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2707
		atomic_inc(&adapter->irq_sem);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2708
		E1000_WRITE_REG(hw, IMC, ~0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2709
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2710
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2711
	for(i = 0; i < E1000_MAX_INTR; i++)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2712
		if(unlikely(!adapter->clean_rx(adapter) &
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2713
		   !e1000_clean_tx_irq(adapter)))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2714
			break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2715
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2716
	if(hw->mac_type == e1000_82547 || hw->mac_type == e1000_82547_rev_2)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2717
		e1000_irq_enable(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2718
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2719
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2720
	return IRQ_HANDLED;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2721
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2722
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2723
#ifdef CONFIG_E1000_NAPI
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2724
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2725
 * e1000_clean - NAPI Rx polling callback
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2726
 * @adapter: board private structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2727
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2728
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2729
static int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2730
e1000_clean(struct net_device *netdev, int *budget) // never called for EtherCAT
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2731
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2732
	struct e1000_adapter *adapter = netdev_priv(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2733
	int work_to_do = min(*budget, netdev->quota);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2734
	int tx_cleaned;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2735
	int work_done = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2736
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2737
	tx_cleaned = e1000_clean_tx_irq(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2738
	adapter->clean_rx(adapter, &work_done, work_to_do);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2739
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2740
	*budget -= work_done;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2741
	netdev->quota -= work_done;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2742
	
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2743
	if ((!tx_cleaned && (work_done == 0)) || !netif_running(netdev)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2744
	/* If no Tx and not enough Rx work done, exit the polling mode */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2745
		netif_rx_complete(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2746
		e1000_irq_enable(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2747
		return 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2748
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2749
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2750
	return 1;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2751
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2752
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2753
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2754
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2755
 * e1000_clean_tx_irq - Reclaim resources after transmit completes
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2756
 * @adapter: board private structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2757
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2758
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2759
static boolean_t
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2760
e1000_clean_tx_irq(struct e1000_adapter *adapter)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2761
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2762
	struct e1000_desc_ring *tx_ring = &adapter->tx_ring;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2763
	struct net_device *netdev = adapter->netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2764
	struct e1000_tx_desc *tx_desc, *eop_desc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2765
	struct e1000_buffer *buffer_info;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2766
	unsigned int i, eop;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2767
	boolean_t cleaned = FALSE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2768
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2769
	i = tx_ring->next_to_clean;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2770
	eop = tx_ring->buffer_info[i].next_to_watch;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2771
	eop_desc = E1000_TX_DESC(*tx_ring, eop);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2772
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2773
	while(eop_desc->upper.data & cpu_to_le32(E1000_TXD_STAT_DD)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2774
		/* Premature writeback of Tx descriptors clear (free buffers
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2775
		 * and unmap pci_mapping) previous_buffer_info */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2776
		if (likely(adapter->previous_buffer_info.skb != NULL)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2777
			e1000_unmap_and_free_tx_resource(adapter,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2778
					&adapter->previous_buffer_info);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2779
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2780
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2781
		for(cleaned = FALSE; !cleaned; ) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2782
			tx_desc = E1000_TX_DESC(*tx_ring, i);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2783
			buffer_info = &tx_ring->buffer_info[i];
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2784
			cleaned = (i == eop);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2785
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2786
#ifdef NETIF_F_TSO
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2787
			if (!(netdev->features & NETIF_F_TSO)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2788
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2789
				e1000_unmap_and_free_tx_resource(adapter,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2790
				                                 buffer_info);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2791
#ifdef NETIF_F_TSO
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2792
			} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2793
				if (cleaned) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2794
					memcpy(&adapter->previous_buffer_info,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2795
					       buffer_info,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2796
					       sizeof(struct e1000_buffer));
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2797
					memset(buffer_info, 0,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2798
					       sizeof(struct e1000_buffer));
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2799
				} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2800
					e1000_unmap_and_free_tx_resource(
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2801
					    adapter, buffer_info);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2802
				}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2803
			}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2804
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2805
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2806
			tx_desc->buffer_addr = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2807
			tx_desc->lower.data = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2808
			tx_desc->upper.data = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2809
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2810
			if(unlikely(++i == tx_ring->count)) i = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2811
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2812
		
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2813
		eop = tx_ring->buffer_info[i].next_to_watch;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2814
		eop_desc = E1000_TX_DESC(*tx_ring, eop);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2815
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2816
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2817
	tx_ring->next_to_clean = i;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2818
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2819
	if (!adapter->ecdev) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2820
		spin_lock(&adapter->tx_lock);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2821
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2822
		if(unlikely(cleaned && netif_queue_stopped(netdev) &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2823
					netif_carrier_ok(netdev)))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2824
			netif_wake_queue(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2825
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2826
		spin_unlock(&adapter->tx_lock);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2827
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2828
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2829
	if(!adapter->ecdev && adapter->detect_tx_hung) {
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2830
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2831
		/* Detect a transmit hang in hardware, this serializes the
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2832
		 * check with the clearing of time_stamp and movement of i */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2833
		adapter->detect_tx_hung = FALSE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2834
		if (tx_ring->buffer_info[i].dma &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2835
		    time_after(jiffies, tx_ring->buffer_info[i].time_stamp + HZ)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2836
		    && !(E1000_READ_REG(&adapter->hw, STATUS) &
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2837
			E1000_STATUS_TXOFF)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2838
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2839
			/* detected Tx unit hang */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2840
			i = tx_ring->next_to_clean;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2841
			eop = tx_ring->buffer_info[i].next_to_watch;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2842
			eop_desc = E1000_TX_DESC(*tx_ring, eop);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2843
			DPRINTK(DRV, ERR, "Detected Tx Unit Hang\n"
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2844
					"  TDH                  <%x>\n"
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2845
					"  TDT                  <%x>\n"
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2846
					"  next_to_use          <%x>\n"
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2847
					"  next_to_clean        <%x>\n"
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2848
					"buffer_info[next_to_clean]\n"
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2849
					"  dma                  <%zx>\n"
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2850
					"  time_stamp           <%lx>\n"
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2851
					"  next_to_watch        <%x>\n"
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2852
					"  jiffies              <%lx>\n"
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2853
					"  next_to_watch.status <%x>\n",
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2854
				E1000_READ_REG(&adapter->hw, TDH),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2855
				E1000_READ_REG(&adapter->hw, TDT),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2856
				tx_ring->next_to_use,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2857
				i,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2858
				tx_ring->buffer_info[i].dma,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2859
				tx_ring->buffer_info[i].time_stamp,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2860
				eop,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2861
				jiffies,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2862
				eop_desc->upper.fields.status);
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2863
			netif_stop_queue(netdev);
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2864
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2865
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2866
#ifdef NETIF_F_TSO
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2867
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2868
	if( unlikely(!(eop_desc->upper.data & cpu_to_le32(E1000_TXD_STAT_DD)) &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2869
	    time_after(jiffies, adapter->previous_buffer_info.time_stamp + HZ)))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2870
		e1000_unmap_and_free_tx_resource(
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2871
		    adapter, &adapter->previous_buffer_info);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2872
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2873
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2874
	return cleaned;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2875
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2876
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2877
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2878
 * e1000_rx_checksum - Receive Checksum Offload for 82543
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2879
 * @adapter:     board private structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2880
 * @status_err:  receive descriptor status and error fields
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2881
 * @csum:        receive descriptor csum field
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2882
 * @sk_buff:     socket buffer with received data
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2883
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2884
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2885
static inline void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2886
e1000_rx_checksum(struct e1000_adapter *adapter,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2887
		  uint32_t status_err, uint32_t csum,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2888
		  struct sk_buff *skb)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2889
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2890
	uint16_t status = (uint16_t)status_err;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2891
	uint8_t errors = (uint8_t)(status_err >> 24);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2892
	skb->ip_summed = CHECKSUM_NONE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2893
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2894
	/* 82543 or newer only */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2895
	if(unlikely(adapter->hw.mac_type < e1000_82543)) return;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2896
	/* Ignore Checksum bit is set */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2897
	if(unlikely(status & E1000_RXD_STAT_IXSM)) return;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2898
	/* TCP/UDP checksum error bit is set */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2899
	if(unlikely(errors & E1000_RXD_ERR_TCPE)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2900
		/* let the stack verify checksum errors */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2901
		adapter->hw_csum_err++;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2902
		return;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2903
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2904
	/* TCP/UDP Checksum has not been calculated */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2905
	if(adapter->hw.mac_type <= e1000_82547_rev_2) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2906
		if(!(status & E1000_RXD_STAT_TCPCS))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2907
			return;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2908
	} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2909
		if(!(status & (E1000_RXD_STAT_TCPCS | E1000_RXD_STAT_UDPCS)))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2910
			return;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2911
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2912
	/* It must be a TCP or UDP packet with a valid checksum */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2913
	if (likely(status & E1000_RXD_STAT_TCPCS)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2914
		/* TCP checksum is good */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2915
		skb->ip_summed = CHECKSUM_UNNECESSARY;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2916
	} else if (adapter->hw.mac_type > e1000_82547_rev_2) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2917
		/* IP fragment with UDP payload */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2918
		/* Hardware complements the payload checksum, so we undo it
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2919
		 * and then put the value in host order for further stack use.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2920
		 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2921
		csum = ntohl(csum ^ 0xFFFF);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2922
		skb->csum = csum;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2923
		skb->ip_summed = CHECKSUM_HW;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2924
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2925
	adapter->hw_csum_good++;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2926
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2927
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2928
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2929
 * e1000_clean_rx_irq - Send received data up the network stack; legacy
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2930
 * @adapter: board private structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2931
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2932
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2933
static boolean_t
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2934
#ifdef CONFIG_E1000_NAPI
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2935
e1000_clean_rx_irq(struct e1000_adapter *adapter, int *work_done,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2936
                   int work_to_do)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2937
#else
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2938
e1000_clean_rx_irq(struct e1000_adapter *adapter)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2939
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2940
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2941
	struct e1000_desc_ring *rx_ring = &adapter->rx_ring;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2942
	struct net_device *netdev = adapter->netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2943
	struct pci_dev *pdev = adapter->pdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2944
	struct e1000_rx_desc *rx_desc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2945
	struct e1000_buffer *buffer_info;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2946
	struct sk_buff *skb;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2947
	unsigned long flags;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2948
	uint32_t length;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2949
	uint8_t last_byte;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2950
	unsigned int i;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2951
	boolean_t cleaned = FALSE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2952
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2953
	i = rx_ring->next_to_clean;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2954
	rx_desc = E1000_RX_DESC(*rx_ring, i);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2955
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2956
	while(rx_desc->status & E1000_RXD_STAT_DD) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2957
		buffer_info = &rx_ring->buffer_info[i];
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2958
#ifdef CONFIG_E1000_NAPI
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2959
		if(*work_done >= work_to_do)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2960
			break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2961
		(*work_done)++;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2962
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2963
		cleaned = TRUE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2964
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2965
		pci_unmap_single(pdev,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2966
		                 buffer_info->dma,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2967
		                 buffer_info->length,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2968
		                 PCI_DMA_FROMDEVICE);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2969
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2970
		skb = buffer_info->skb;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2971
		length = le16_to_cpu(rx_desc->length);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2972
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2973
		if(unlikely(!(rx_desc->status & E1000_RXD_STAT_EOP))) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2974
			/* All receives must fit into a single buffer */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2975
			E1000_DBG("%s: Receive packet consumed multiple"
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2976
				  " buffers\n", netdev->name);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2977
			if (!adapter->ecdev) dev_kfree_skb_irq(skb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2978
			goto next_desc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2979
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2980
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2981
		if(!adapter->ecdev && unlikely(rx_desc->errors & E1000_RXD_ERR_FRAME_ERR_MASK)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2982
			last_byte = *(skb->data + length - 1);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2983
			if(TBI_ACCEPT(&adapter->hw, rx_desc->status,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2984
			              rx_desc->errors, length, last_byte)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2985
				spin_lock_irqsave(&adapter->stats_lock, flags);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2986
				e1000_tbi_adjust_stats(&adapter->hw,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2987
				                       &adapter->stats,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2988
				                       length, skb->data);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2989
				spin_unlock_irqrestore(&adapter->stats_lock,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2990
				                       flags);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2991
				length--;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2992
			} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2993
				dev_kfree_skb_irq(skb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2994
				goto next_desc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2995
			}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2996
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2997
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2998
		/* Good Receive */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2999
		skb_put(skb, length - ETHERNET_FCS_SIZE);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3000
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3001
		/* Receive Checksum Offload */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3002
		e1000_rx_checksum(adapter,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3003
				  (uint32_t)(rx_desc->status) |
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3004
				  ((uint32_t)(rx_desc->errors) << 24),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3005
				  rx_desc->csum, skb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3006
		if (adapter->ecdev) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3007
			ecdev_receive(adapter->ecdev, skb->data, length);
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3008
			skb_trim(skb, 0);
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3009
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3010
			if(unlikely((i & ~(E1000_RX_BUFFER_WRITE - 1)) == i)) {
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3011
				/* Force memory writes to complete before letting h/w
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3012
				 * know there are new descriptors to fetch.  (Only
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3013
				 * applicable for weak-ordered memory model archs,
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3014
				 * such as IA-64). */
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3015
				wmb();
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3016
				E1000_WRITE_REG(&adapter->hw, RDT, i);
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3017
			}
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3018
		} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3019
			skb->protocol = eth_type_trans(skb, netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3020
#ifdef CONFIG_E1000_NAPI
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3021
			if(unlikely(adapter->vlgrp &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3022
						(rx_desc->status & E1000_RXD_STAT_VP))) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3023
				vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3024
						le16_to_cpu(rx_desc->special) &
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3025
						E1000_RXD_SPC_VLAN_MASK);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3026
			} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3027
				netif_receive_skb(skb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3028
			}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3029
#else /* CONFIG_E1000_NAPI */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3030
			if(unlikely(adapter->vlgrp &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3031
						(rx_desc->status & E1000_RXD_STAT_VP))) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3032
				vlan_hwaccel_rx(skb, adapter->vlgrp,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3033
						le16_to_cpu(rx_desc->special) &
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3034
						E1000_RXD_SPC_VLAN_MASK);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3035
			} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3036
				netif_rx(skb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3037
			}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3038
#endif /* CONFIG_E1000_NAPI */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3039
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3040
		netdev->last_rx = jiffies;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3041
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3042
next_desc:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3043
		rx_desc->status = 0;
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3044
		if (!adapter->ecdev) buffer_info->skb = NULL;
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3045
		if(unlikely(++i == rx_ring->count)) i = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3046
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3047
		rx_desc = E1000_RX_DESC(*rx_ring, i);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3048
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3049
	rx_ring->next_to_clean = i;
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3050
	if (adapter->ecdev) {
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3051
		rx_ring->next_to_use = i;
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3052
	} else {
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3053
		adapter->alloc_rx_buf(adapter);
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3054
	}
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3055
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3056
	return cleaned;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3057
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3058
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3059
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3060
 * e1000_clean_rx_irq_ps - Send received data up the network stack; packet split
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3061
 * @adapter: board private structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3062
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3063
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3064
static boolean_t
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3065
#ifdef CONFIG_E1000_NAPI
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3066
e1000_clean_rx_irq_ps(struct e1000_adapter *adapter, int *work_done,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3067
                      int work_to_do)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3068
#else
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3069
e1000_clean_rx_irq_ps(struct e1000_adapter *adapter)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3070
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3071
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3072
	struct e1000_desc_ring *rx_ring = &adapter->rx_ring;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3073
	union e1000_rx_desc_packet_split *rx_desc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3074
	struct net_device *netdev = adapter->netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3075
	struct pci_dev *pdev = adapter->pdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3076
	struct e1000_buffer *buffer_info;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3077
	struct e1000_ps_page *ps_page;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3078
	struct e1000_ps_page_dma *ps_page_dma;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3079
	struct sk_buff *skb;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3080
	unsigned int i, j;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3081
	uint32_t length, staterr;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3082
	boolean_t cleaned = FALSE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3083
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3084
	i = rx_ring->next_to_clean;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3085
	rx_desc = E1000_RX_DESC_PS(*rx_ring, i);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3086
	staterr = le32_to_cpu(rx_desc->wb.middle.status_error);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3087
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3088
	while(staterr & E1000_RXD_STAT_DD) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3089
		buffer_info = &rx_ring->buffer_info[i];
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3090
		ps_page = &rx_ring->ps_page[i];
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3091
		ps_page_dma = &rx_ring->ps_page_dma[i];
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3092
#ifdef CONFIG_E1000_NAPI
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3093
		if(unlikely(*work_done >= work_to_do))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3094
			break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3095
		(*work_done)++;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3096
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3097
		cleaned = TRUE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3098
		pci_unmap_single(pdev, buffer_info->dma,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3099
				 buffer_info->length,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3100
				 PCI_DMA_FROMDEVICE);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3101
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3102
		skb = buffer_info->skb;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3103
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3104
		if(unlikely(!(staterr & E1000_RXD_STAT_EOP))) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3105
			E1000_DBG("%s: Packet Split buffers didn't pick up"
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3106
				  " the full packet\n", netdev->name);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3107
			if (!adapter->ecdev) dev_kfree_skb_irq(skb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3108
			goto next_desc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3109
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3110
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3111
		if(unlikely(staterr & E1000_RXDEXT_ERR_FRAME_ERR_MASK)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3112
			if (!adapter->ecdev) dev_kfree_skb_irq(skb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3113
			goto next_desc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3114
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3115
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3116
		length = le16_to_cpu(rx_desc->wb.middle.length0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3117
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3118
		if(unlikely(!length)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3119
			E1000_DBG("%s: Last part of the packet spanning"
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3120
				  " multiple descriptors\n", netdev->name);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3121
			if (!adapter->ecdev) dev_kfree_skb_irq(skb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3122
			goto next_desc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3123
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3124
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3125
		/* Good Receive */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3126
		skb_put(skb, length);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3127
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3128
		for(j = 0; j < PS_PAGE_BUFFERS; j++) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3129
			if(!(length = le16_to_cpu(rx_desc->wb.upper.length[j])))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3130
				break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3131
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3132
			pci_unmap_page(pdev, ps_page_dma->ps_page_dma[j],
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3133
					PAGE_SIZE, PCI_DMA_FROMDEVICE);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3134
			ps_page_dma->ps_page_dma[j] = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3135
			skb_shinfo(skb)->frags[j].page =
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3136
				ps_page->ps_page[j];
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3137
			ps_page->ps_page[j] = NULL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3138
			skb_shinfo(skb)->frags[j].page_offset = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3139
			skb_shinfo(skb)->frags[j].size = length;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3140
			skb_shinfo(skb)->nr_frags++;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3141
			skb->len += length;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3142
			skb->data_len += length;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3143
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3144
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3145
		e1000_rx_checksum(adapter, staterr,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3146
				  rx_desc->wb.lower.hi_dword.csum_ip.csum, skb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3147
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3148
#ifdef HAVE_RX_ZERO_COPY
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3149
		if(likely(rx_desc->wb.upper.header_status &
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3150
			  E1000_RXDPS_HDRSTAT_HDRSP))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3151
			skb_shinfo(skb)->zero_copy = TRUE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3152
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3153
		if (adapter->ecdev) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3154
			ecdev_receive(adapter->ecdev, skb->data, length);
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3155
			skb_trim(skb, 0);
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3156
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3157
			if(unlikely((i & ~(E1000_RX_BUFFER_WRITE - 1)) == i)) {
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3158
				/* Force memory writes to complete before letting h/w
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3159
				 * know there are new descriptors to fetch.  (Only
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3160
				 * applicable for weak-ordered memory model archs,
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3161
				 * such as IA-64). */
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3162
				wmb();
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3163
				/* Hardware increments by 16 bytes, but packet split
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3164
				 * descriptors are 32 bytes...so we increment tail
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3165
				 * twice as much.
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3166
				 */
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3167
				E1000_WRITE_REG(&adapter->hw, RDT, i<<1);
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3168
			}
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3169
		} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3170
			skb->protocol = eth_type_trans(skb, netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3171
#ifdef CONFIG_E1000_NAPI
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3172
			if(unlikely(adapter->vlgrp && (staterr & E1000_RXD_STAT_VP))) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3173
				vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3174
						le16_to_cpu(rx_desc->wb.middle.vlan) &
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3175
						E1000_RXD_SPC_VLAN_MASK);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3176
			} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3177
				netif_receive_skb(skb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3178
			}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3179
#else /* CONFIG_E1000_NAPI */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3180
			if(unlikely(adapter->vlgrp && (staterr & E1000_RXD_STAT_VP))) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3181
				vlan_hwaccel_rx(skb, adapter->vlgrp,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3182
						le16_to_cpu(rx_desc->wb.middle.vlan) &
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3183
						E1000_RXD_SPC_VLAN_MASK);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3184
			} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3185
				netif_rx(skb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3186
			}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3187
#endif /* CONFIG_E1000_NAPI */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3188
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3189
		netdev->last_rx = jiffies;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3190
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3191
next_desc:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3192
		rx_desc->wb.middle.status_error &= ~0xFF;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3193
		if (!adapter->ecdev) buffer_info->skb = NULL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3194
		if(unlikely(++i == rx_ring->count)) i = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3195
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3196
		rx_desc = E1000_RX_DESC_PS(*rx_ring, i);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3197
		staterr = le32_to_cpu(rx_desc->wb.middle.status_error);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3198
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3199
	rx_ring->next_to_clean = i;
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3200
	if (adapter->ecdev) { 
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3201
		rx_ring->next_to_use = i;
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3202
	} else {
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3203
		adapter->alloc_rx_buf(adapter);
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3204
	}
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3205
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3206
	return cleaned;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3207
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3208
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3209
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3210
 * e1000_alloc_rx_buffers - Replace used receive buffers; legacy & extended
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3211
 * @adapter: address of board private structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3212
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3213
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3214
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3215
e1000_alloc_rx_buffers(struct e1000_adapter *adapter)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3216
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3217
	struct e1000_desc_ring *rx_ring = &adapter->rx_ring;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3218
	struct net_device *netdev = adapter->netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3219
	struct pci_dev *pdev = adapter->pdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3220
	struct e1000_rx_desc *rx_desc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3221
	struct e1000_buffer *buffer_info;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3222
	struct sk_buff *skb;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3223
	unsigned int i;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3224
	unsigned int bufsz = adapter->rx_buffer_len + NET_IP_ALIGN;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3225
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3226
	i = rx_ring->next_to_use;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3227
	buffer_info = &rx_ring->buffer_info[i];
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3228
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3229
	while(!buffer_info->skb) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3230
		skb = dev_alloc_skb(bufsz);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3231
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3232
		if(unlikely(!skb)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3233
			/* Better luck next round */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3234
			break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3235
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3236
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3237
		/* Fix for errata 23, can't cross 64kB boundary */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3238
		if (!e1000_check_64k_bound(adapter, skb->data, bufsz)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3239
			struct sk_buff *oldskb = skb;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3240
			DPRINTK(RX_ERR, ERR, "skb align check failed: %u bytes "
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3241
					     "at %p\n", bufsz, skb->data);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3242
			/* Try again, without freeing the previous */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3243
			skb = dev_alloc_skb(bufsz);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3244
			/* Failed allocation, critical failure */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3245
			if (!skb) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3246
				dev_kfree_skb(oldskb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3247
				break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3248
			}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3249
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3250
			if (!e1000_check_64k_bound(adapter, skb->data, bufsz)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3251
				/* give up */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3252
				dev_kfree_skb(skb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3253
				dev_kfree_skb(oldskb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3254
				break; /* while !buffer_info->skb */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3255
			} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3256
				/* Use new allocation */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3257
				dev_kfree_skb(oldskb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3258
			}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3259
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3260
		/* Make buffer alignment 2 beyond a 16 byte boundary
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3261
		 * this will result in a 16 byte aligned IP header after
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3262
		 * the 14 byte MAC header is removed
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3263
		 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3264
		skb_reserve(skb, NET_IP_ALIGN);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3265
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3266
		skb->dev = netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3267
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3268
		buffer_info->skb = skb;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3269
		buffer_info->length = adapter->rx_buffer_len;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3270
		buffer_info->dma = pci_map_single(pdev,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3271
						  skb->data,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3272
						  adapter->rx_buffer_len,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3273
						  PCI_DMA_FROMDEVICE);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3274
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3275
		/* Fix for errata 23, can't cross 64kB boundary */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3276
		if (!e1000_check_64k_bound(adapter,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3277
					(void *)(unsigned long)buffer_info->dma,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3278
					adapter->rx_buffer_len)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3279
			DPRINTK(RX_ERR, ERR,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3280
				"dma align check failed: %u bytes at %p\n",
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3281
				adapter->rx_buffer_len,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3282
				(void *)(unsigned long)buffer_info->dma);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3283
			dev_kfree_skb(skb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3284
			buffer_info->skb = NULL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3285
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3286
			pci_unmap_single(pdev, buffer_info->dma,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3287
					 adapter->rx_buffer_len,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3288
					 PCI_DMA_FROMDEVICE);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3289
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3290
			break; /* while !buffer_info->skb */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3291
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3292
		rx_desc = E1000_RX_DESC(*rx_ring, i);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3293
		rx_desc->buffer_addr = cpu_to_le64(buffer_info->dma);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3294
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3295
		if(unlikely((i & ~(E1000_RX_BUFFER_WRITE - 1)) == i)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3296
			/* Force memory writes to complete before letting h/w
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3297
			 * know there are new descriptors to fetch.  (Only
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3298
			 * applicable for weak-ordered memory model archs,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3299
			 * such as IA-64). */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3300
			wmb();
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3301
			E1000_WRITE_REG(&adapter->hw, RDT, i);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3302
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3303
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3304
		if(unlikely(++i == rx_ring->count)) i = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3305
		buffer_info = &rx_ring->buffer_info[i];
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3306
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3307
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3308
	rx_ring->next_to_use = i;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3309
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3310
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3311
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3312
 * e1000_alloc_rx_buffers_ps - Replace used receive buffers; packet split
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3313
 * @adapter: address of board private structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3314
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3315
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3316
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3317
e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3318
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3319
	struct e1000_desc_ring *rx_ring = &adapter->rx_ring;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3320
	struct net_device *netdev = adapter->netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3321
	struct pci_dev *pdev = adapter->pdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3322
	union e1000_rx_desc_packet_split *rx_desc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3323
	struct e1000_buffer *buffer_info;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3324
	struct e1000_ps_page *ps_page;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3325
	struct e1000_ps_page_dma *ps_page_dma;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3326
	struct sk_buff *skb;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3327
	unsigned int i, j;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3328
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3329
	i = rx_ring->next_to_use;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3330
	buffer_info = &rx_ring->buffer_info[i];
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3331
	ps_page = &rx_ring->ps_page[i];
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3332
	ps_page_dma = &rx_ring->ps_page_dma[i];
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3333
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3334
	while(!buffer_info->skb) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3335
		rx_desc = E1000_RX_DESC_PS(*rx_ring, i);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3336
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3337
		for(j = 0; j < PS_PAGE_BUFFERS; j++) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3338
			if(unlikely(!ps_page->ps_page[j])) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3339
				ps_page->ps_page[j] =
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3340
					alloc_page(GFP_ATOMIC);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3341
				if(unlikely(!ps_page->ps_page[j]))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3342
					goto no_buffers;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3343
				ps_page_dma->ps_page_dma[j] =
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3344
					pci_map_page(pdev,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3345
						     ps_page->ps_page[j],
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3346
						     0, PAGE_SIZE,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3347
						     PCI_DMA_FROMDEVICE);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3348
			}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3349
			/* Refresh the desc even if buffer_addrs didn't
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3350
			 * change because each write-back erases this info.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3351
			 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3352
			rx_desc->read.buffer_addr[j+1] =
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3353
				cpu_to_le64(ps_page_dma->ps_page_dma[j]);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3354
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3355
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3356
		skb = dev_alloc_skb(adapter->rx_ps_bsize0 + NET_IP_ALIGN);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3357
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3358
		if(unlikely(!skb))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3359
			break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3360
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3361
		/* Make buffer alignment 2 beyond a 16 byte boundary
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3362
		 * this will result in a 16 byte aligned IP header after
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3363
		 * the 14 byte MAC header is removed
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3364
		 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3365
		skb_reserve(skb, NET_IP_ALIGN);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3366
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3367
		skb->dev = netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3368
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3369
		buffer_info->skb = skb;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3370
		buffer_info->length = adapter->rx_ps_bsize0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3371
		buffer_info->dma = pci_map_single(pdev, skb->data,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3372
						  adapter->rx_ps_bsize0,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3373
						  PCI_DMA_FROMDEVICE);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3374
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3375
		rx_desc->read.buffer_addr[0] = cpu_to_le64(buffer_info->dma);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3376
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3377
		if(unlikely((i & ~(E1000_RX_BUFFER_WRITE - 1)) == i)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3378
			/* Force memory writes to complete before letting h/w
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3379
			 * know there are new descriptors to fetch.  (Only
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3380
			 * applicable for weak-ordered memory model archs,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3381
			 * such as IA-64). */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3382
			wmb();
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3383
			/* Hardware increments by 16 bytes, but packet split
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3384
			 * descriptors are 32 bytes...so we increment tail
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3385
			 * twice as much.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3386
			 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3387
			E1000_WRITE_REG(&adapter->hw, RDT, i<<1);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3388
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3389
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3390
		if(unlikely(++i == rx_ring->count)) i = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3391
		buffer_info = &rx_ring->buffer_info[i];
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3392
		ps_page = &rx_ring->ps_page[i];
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3393
		ps_page_dma = &rx_ring->ps_page_dma[i];
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3394
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3395
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3396
no_buffers:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3397
	rx_ring->next_to_use = i;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3398
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3399
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3400
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3401
 * e1000_smartspeed - Workaround for SmartSpeed on 82541 and 82547 controllers.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3402
 * @adapter:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3403
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3404
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3405
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3406
e1000_smartspeed(struct e1000_adapter *adapter)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3407
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3408
	uint16_t phy_status;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3409
	uint16_t phy_ctrl;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3410
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3411
	if((adapter->hw.phy_type != e1000_phy_igp) || !adapter->hw.autoneg ||
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3412
	   !(adapter->hw.autoneg_advertised & ADVERTISE_1000_FULL))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3413
		return;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3414
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3415
	if(adapter->smartspeed == 0) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3416
		/* If Master/Slave config fault is asserted twice,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3417
		 * we assume back-to-back */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3418
		e1000_read_phy_reg(&adapter->hw, PHY_1000T_STATUS, &phy_status);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3419
		if(!(phy_status & SR_1000T_MS_CONFIG_FAULT)) return;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3420
		e1000_read_phy_reg(&adapter->hw, PHY_1000T_STATUS, &phy_status);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3421
		if(!(phy_status & SR_1000T_MS_CONFIG_FAULT)) return;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3422
		e1000_read_phy_reg(&adapter->hw, PHY_1000T_CTRL, &phy_ctrl);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3423
		if(phy_ctrl & CR_1000T_MS_ENABLE) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3424
			phy_ctrl &= ~CR_1000T_MS_ENABLE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3425
			e1000_write_phy_reg(&adapter->hw, PHY_1000T_CTRL,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3426
					    phy_ctrl);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3427
			adapter->smartspeed++;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3428
			if(!e1000_phy_setup_autoneg(&adapter->hw) &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3429
			   !e1000_read_phy_reg(&adapter->hw, PHY_CTRL,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3430
				   	       &phy_ctrl)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3431
				phy_ctrl |= (MII_CR_AUTO_NEG_EN |
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3432
					     MII_CR_RESTART_AUTO_NEG);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3433
				e1000_write_phy_reg(&adapter->hw, PHY_CTRL,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3434
						    phy_ctrl);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3435
			}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3436
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3437
		return;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3438
	} else if(adapter->smartspeed == E1000_SMARTSPEED_DOWNSHIFT) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3439
		/* If still no link, perhaps using 2/3 pair cable */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3440
		e1000_read_phy_reg(&adapter->hw, PHY_1000T_CTRL, &phy_ctrl);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3441
		phy_ctrl |= CR_1000T_MS_ENABLE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3442
		e1000_write_phy_reg(&adapter->hw, PHY_1000T_CTRL, phy_ctrl);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3443
		if(!e1000_phy_setup_autoneg(&adapter->hw) &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3444
		   !e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &phy_ctrl)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3445
			phy_ctrl |= (MII_CR_AUTO_NEG_EN |
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3446
				     MII_CR_RESTART_AUTO_NEG);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3447
			e1000_write_phy_reg(&adapter->hw, PHY_CTRL, phy_ctrl);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3448
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3449
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3450
	/* Restart process after E1000_SMARTSPEED_MAX iterations */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3451
	if(adapter->smartspeed++ == E1000_SMARTSPEED_MAX)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3452
		adapter->smartspeed = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3453
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3454
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3455
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3456
 * e1000_ioctl -
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3457
 * @netdev:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3458
 * @ifreq:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3459
 * @cmd:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3460
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3461
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3462
static int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3463
e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3464
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3465
	switch (cmd) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3466
	case SIOCGMIIPHY:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3467
	case SIOCGMIIREG:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3468
	case SIOCSMIIREG:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3469
		return e1000_mii_ioctl(netdev, ifr, cmd);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3470
	default:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3471
		return -EOPNOTSUPP;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3472
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3473
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3474
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3475
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3476
 * e1000_mii_ioctl -
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3477
 * @netdev:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3478
 * @ifreq:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3479
 * @cmd:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3480
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3481
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3482
static int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3483
e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3484
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3485
	struct e1000_adapter *adapter = netdev_priv(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3486
	struct mii_ioctl_data *data = if_mii(ifr);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3487
	int retval;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3488
	uint16_t mii_reg;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3489
	uint16_t spddplx;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3490
	unsigned long flags;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3491
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3492
	if(adapter->hw.media_type != e1000_media_type_copper)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3493
		return -EOPNOTSUPP;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3494
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3495
	switch (cmd) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3496
	case SIOCGMIIPHY:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3497
		data->phy_id = adapter->hw.phy_addr;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3498
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3499
	case SIOCGMIIREG:
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3500
		if(adapter->ecdev || !capable(CAP_NET_ADMIN))
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3501
			return -EPERM;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3502
		spin_lock_irqsave(&adapter->stats_lock, flags);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3503
		if(e1000_read_phy_reg(&adapter->hw, data->reg_num & 0x1F,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3504
				   &data->val_out)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3505
			spin_unlock_irqrestore(&adapter->stats_lock, flags);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3506
			return -EIO;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3507
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3508
		spin_unlock_irqrestore(&adapter->stats_lock, flags);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3509
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3510
	case SIOCSMIIREG:
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3511
		if(adapter->ecdev || !capable(CAP_NET_ADMIN))
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3512
			return -EPERM;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3513
		if(data->reg_num & ~(0x1F))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3514
			return -EFAULT;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3515
		mii_reg = data->val_in;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3516
		spin_lock_irqsave(&adapter->stats_lock, flags);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3517
		if(e1000_write_phy_reg(&adapter->hw, data->reg_num,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3518
					mii_reg)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3519
			spin_unlock_irqrestore(&adapter->stats_lock, flags);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3520
			return -EIO;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3521
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3522
		if(adapter->hw.phy_type == e1000_phy_m88) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3523
			switch (data->reg_num) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3524
			case PHY_CTRL:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3525
				if(mii_reg & MII_CR_POWER_DOWN)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3526
					break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3527
				if(mii_reg & MII_CR_AUTO_NEG_EN) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3528
					adapter->hw.autoneg = 1;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3529
					adapter->hw.autoneg_advertised = 0x2F;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3530
				} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3531
					if (mii_reg & 0x40)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3532
						spddplx = SPEED_1000;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3533
					else if (mii_reg & 0x2000)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3534
						spddplx = SPEED_100;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3535
					else
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3536
						spddplx = SPEED_10;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3537
					spddplx += (mii_reg & 0x100)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3538
						   ? FULL_DUPLEX :
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3539
						   HALF_DUPLEX;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3540
					retval = e1000_set_spd_dplx(adapter,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3541
								    spddplx);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3542
					if(retval) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3543
						spin_unlock_irqrestore(
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3544
							&adapter->stats_lock, 
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3545
							flags);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3546
						return retval;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3547
					}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3548
				}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3549
				if(adapter->ecdev || netif_running(adapter->netdev)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3550
					e1000_down(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3551
					e1000_up(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3552
				} else
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3553
					e1000_reset(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3554
				break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3555
			case M88E1000_PHY_SPEC_CTRL:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3556
			case M88E1000_EXT_PHY_SPEC_CTRL:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3557
				if(e1000_phy_reset(&adapter->hw)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3558
					spin_unlock_irqrestore(
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3559
						&adapter->stats_lock, flags);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3560
					return -EIO;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3561
				}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3562
				break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3563
			}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3564
		} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3565
			switch (data->reg_num) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3566
			case PHY_CTRL:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3567
				if(mii_reg & MII_CR_POWER_DOWN)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3568
					break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3569
				if(adapter->ecdev || netif_running(adapter->netdev)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3570
					e1000_down(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3571
					e1000_up(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3572
				} else
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3573
					e1000_reset(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3574
				break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3575
			}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3576
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3577
		spin_unlock_irqrestore(&adapter->stats_lock, flags);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3578
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3579
	default:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3580
		return -EOPNOTSUPP;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3581
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3582
	return E1000_SUCCESS;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3583
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3584
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3585
void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3586
e1000_pci_set_mwi(struct e1000_hw *hw)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3587
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3588
	struct e1000_adapter *adapter = hw->back;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3589
	int ret_val = pci_set_mwi(adapter->pdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3590
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3591
	if(ret_val)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3592
		DPRINTK(PROBE, ERR, "Error in setting MWI\n");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3593
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3594
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3595
void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3596
e1000_pci_clear_mwi(struct e1000_hw *hw)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3597
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3598
	struct e1000_adapter *adapter = hw->back;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3599
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3600
	pci_clear_mwi(adapter->pdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3601
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3602
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3603
void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3604
e1000_read_pci_cfg(struct e1000_hw *hw, uint32_t reg, uint16_t *value)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3605
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3606
	struct e1000_adapter *adapter = hw->back;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3607
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3608
	pci_read_config_word(adapter->pdev, reg, value);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3609
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3610
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3611
void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3612
e1000_write_pci_cfg(struct e1000_hw *hw, uint32_t reg, uint16_t *value)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3613
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3614
	struct e1000_adapter *adapter = hw->back;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3615
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3616
	pci_write_config_word(adapter->pdev, reg, *value);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3617
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3618
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3619
uint32_t
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3620
e1000_io_read(struct e1000_hw *hw, unsigned long port)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3621
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3622
	return inl(port);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3623
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3624
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3625
void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3626
e1000_io_write(struct e1000_hw *hw, unsigned long port, uint32_t value)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3627
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3628
	outl(value, port);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3629
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3630
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3631
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3632
e1000_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3633
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3634
	struct e1000_adapter *adapter = netdev_priv(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3635
	uint32_t ctrl, rctl;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3636
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3637
	e1000_irq_disable(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3638
	adapter->vlgrp = grp;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3639
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3640
	if(grp) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3641
		/* enable VLAN tag insert/strip */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3642
		ctrl = E1000_READ_REG(&adapter->hw, CTRL);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3643
		ctrl |= E1000_CTRL_VME;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3644
		E1000_WRITE_REG(&adapter->hw, CTRL, ctrl);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3645
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3646
		/* enable VLAN receive filtering */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3647
		rctl = E1000_READ_REG(&adapter->hw, RCTL);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3648
		rctl |= E1000_RCTL_VFE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3649
		rctl &= ~E1000_RCTL_CFIEN;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3650
		E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3651
		e1000_update_mng_vlan(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3652
	} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3653
		/* disable VLAN tag insert/strip */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3654
		ctrl = E1000_READ_REG(&adapter->hw, CTRL);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3655
		ctrl &= ~E1000_CTRL_VME;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3656
		E1000_WRITE_REG(&adapter->hw, CTRL, ctrl);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3657
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3658
		/* disable VLAN filtering */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3659
		rctl = E1000_READ_REG(&adapter->hw, RCTL);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3660
		rctl &= ~E1000_RCTL_VFE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3661
		E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3662
		if(adapter->mng_vlan_id != (uint16_t)E1000_MNG_VLAN_NONE) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3663
			e1000_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3664
			adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3665
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3666
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3667
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3668
	e1000_irq_enable(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3669
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3670
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3671
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3672
e1000_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3673
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3674
	struct e1000_adapter *adapter = netdev_priv(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3675
	uint32_t vfta, index;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3676
	if((adapter->hw.mng_cookie.status &
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3677
		E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3678
		(vid == adapter->mng_vlan_id))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3679
		return;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3680
	/* add VID to filter table */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3681
	index = (vid >> 5) & 0x7F;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3682
	vfta = E1000_READ_REG_ARRAY(&adapter->hw, VFTA, index);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3683
	vfta |= (1 << (vid & 0x1F));
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3684
	e1000_write_vfta(&adapter->hw, index, vfta);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3685
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3686
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3687
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3688
e1000_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3689
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3690
	struct e1000_adapter *adapter = netdev_priv(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3691
	uint32_t vfta, index;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3692
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3693
	e1000_irq_disable(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3694
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3695
	if(adapter->vlgrp)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3696
		adapter->vlgrp->vlan_devices[vid] = NULL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3697
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3698
	e1000_irq_enable(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3699
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3700
	if((adapter->hw.mng_cookie.status &
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3701
		E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3702
		(vid == adapter->mng_vlan_id))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3703
		return;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3704
	/* remove VID from filter table */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3705
	index = (vid >> 5) & 0x7F;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3706
	vfta = E1000_READ_REG_ARRAY(&adapter->hw, VFTA, index);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3707
	vfta &= ~(1 << (vid & 0x1F));
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3708
	e1000_write_vfta(&adapter->hw, index, vfta);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3709
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3710
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3711
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3712
e1000_restore_vlan(struct e1000_adapter *adapter)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3713
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3714
	e1000_vlan_rx_register(adapter->netdev, adapter->vlgrp);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3715
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3716
	if(adapter->vlgrp) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3717
		uint16_t vid;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3718
		for(vid = 0; vid < VLAN_GROUP_ARRAY_LEN; vid++) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3719
			if(!adapter->vlgrp->vlan_devices[vid])
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3720
				continue;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3721
			e1000_vlan_rx_add_vid(adapter->netdev, vid);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3722
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3723
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3724
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3725
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3726
int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3727
e1000_set_spd_dplx(struct e1000_adapter *adapter, uint16_t spddplx)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3728
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3729
	adapter->hw.autoneg = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3730
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3731
	/* Fiber NICs only allow 1000 gbps Full duplex */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3732
	if((adapter->hw.media_type == e1000_media_type_fiber) &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3733
		spddplx != (SPEED_1000 + DUPLEX_FULL)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3734
		DPRINTK(PROBE, ERR, "Unsupported Speed/Duplex configuration\n");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3735
		return -EINVAL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3736
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3737
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3738
	switch(spddplx) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3739
	case SPEED_10 + DUPLEX_HALF:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3740
		adapter->hw.forced_speed_duplex = e1000_10_half;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3741
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3742
	case SPEED_10 + DUPLEX_FULL:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3743
		adapter->hw.forced_speed_duplex = e1000_10_full;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3744
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3745
	case SPEED_100 + DUPLEX_HALF:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3746
		adapter->hw.forced_speed_duplex = e1000_100_half;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3747
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3748
	case SPEED_100 + DUPLEX_FULL:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3749
		adapter->hw.forced_speed_duplex = e1000_100_full;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3750
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3751
	case SPEED_1000 + DUPLEX_FULL:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3752
		adapter->hw.autoneg = 1;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3753
		adapter->hw.autoneg_advertised = ADVERTISE_1000_FULL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3754
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3755
	case SPEED_1000 + DUPLEX_HALF: /* not supported */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3756
	default:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3757
		DPRINTK(PROBE, ERR, "Unsupported Speed/Duplex configuration\n");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3758
		return -EINVAL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3759
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3760
	return 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3761
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3762
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3763
static int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3764
e1000_suspend(struct pci_dev *pdev, uint32_t state)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3765
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3766
	struct net_device *netdev = pci_get_drvdata(pdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3767
	struct e1000_adapter *adapter = netdev_priv(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3768
	uint32_t ctrl, ctrl_ext, rctl, manc, status, swsm;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3769
	uint32_t wufc = adapter->wol;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3770
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3771
	if (!adapter->ecdev)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3772
		netif_device_detach(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3773
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3774
	if (adapter->ecdev || netif_running(netdev))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3775
		e1000_down(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3776
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3777
	status = E1000_READ_REG(&adapter->hw, STATUS);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3778
	if(status & E1000_STATUS_LU)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3779
		wufc &= ~E1000_WUFC_LNKC;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3780
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3781
	if(wufc) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3782
		e1000_setup_rctl(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3783
		e1000_set_multi(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3784
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3785
		/* turn on all-multi mode if wake on multicast is enabled */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3786
		if(adapter->wol & E1000_WUFC_MC) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3787
			rctl = E1000_READ_REG(&adapter->hw, RCTL);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3788
			rctl |= E1000_RCTL_MPE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3789
			E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3790
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3791
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3792
		if(adapter->hw.mac_type >= e1000_82540) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3793
			ctrl = E1000_READ_REG(&adapter->hw, CTRL);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3794
			/* advertise wake from D3Cold */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3795
			#define E1000_CTRL_ADVD3WUC 0x00100000
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3796
			/* phy power management enable */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3797
			#define E1000_CTRL_EN_PHY_PWR_MGMT 0x00200000
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3798
			ctrl |= E1000_CTRL_ADVD3WUC |
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3799
				E1000_CTRL_EN_PHY_PWR_MGMT;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3800
			E1000_WRITE_REG(&adapter->hw, CTRL, ctrl);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3801
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3802
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3803
		if(adapter->hw.media_type == e1000_media_type_fiber ||
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3804
		   adapter->hw.media_type == e1000_media_type_internal_serdes) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3805
			/* keep the laser running in D3 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3806
			ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3807
			ctrl_ext |= E1000_CTRL_EXT_SDP7_DATA;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3808
			E1000_WRITE_REG(&adapter->hw, CTRL_EXT, ctrl_ext);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3809
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3810
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3811
		/* Allow time for pending master requests to run */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3812
		e1000_disable_pciex_master(&adapter->hw);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3813
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3814
		E1000_WRITE_REG(&adapter->hw, WUC, E1000_WUC_PME_EN);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3815
		E1000_WRITE_REG(&adapter->hw, WUFC, wufc);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3816
		pci_enable_wake(pdev, 3, 1);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3817
		pci_enable_wake(pdev, 4, 1); /* 4 == D3 cold */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3818
	} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3819
		E1000_WRITE_REG(&adapter->hw, WUC, 0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3820
		E1000_WRITE_REG(&adapter->hw, WUFC, 0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3821
		pci_enable_wake(pdev, 3, 0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3822
		pci_enable_wake(pdev, 4, 0); /* 4 == D3 cold */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3823
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3824
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3825
	pci_save_state(pdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3826
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3827
	if(adapter->hw.mac_type >= e1000_82540 &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3828
	   adapter->hw.media_type == e1000_media_type_copper) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3829
		manc = E1000_READ_REG(&adapter->hw, MANC);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3830
		if(manc & E1000_MANC_SMBUS_EN) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3831
			manc |= E1000_MANC_ARP_EN;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3832
			E1000_WRITE_REG(&adapter->hw, MANC, manc);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3833
			pci_enable_wake(pdev, 3, 1);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3834
			pci_enable_wake(pdev, 4, 1); /* 4 == D3 cold */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3835
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3836
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3837
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3838
	switch(adapter->hw.mac_type) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3839
	case e1000_82573:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3840
		swsm = E1000_READ_REG(&adapter->hw, SWSM);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3841
		E1000_WRITE_REG(&adapter->hw, SWSM,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3842
				swsm & ~E1000_SWSM_DRV_LOAD);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3843
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3844
	default:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3845
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3846
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3847
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3848
	pci_disable_device(pdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3849
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3850
	state = (state > 0) ? 3 : 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3851
	pci_set_power_state(pdev, state);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3852
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3853
	return 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3854
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3855
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3856
#ifdef CONFIG_PM
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3857
static int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3858
e1000_resume(struct pci_dev *pdev)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3859
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3860
	struct net_device *netdev = pci_get_drvdata(pdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3861
	struct e1000_adapter *adapter = netdev_priv(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3862
	uint32_t manc, ret_val, swsm;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3863
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3864
	pci_set_power_state(pdev, 0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3865
	pci_restore_state(pdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3866
	ret_val = pci_enable_device(pdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3867
	pci_set_master(pdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3868
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3869
	pci_enable_wake(pdev, 3, 0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3870
	pci_enable_wake(pdev, 4, 0); /* 4 == D3 cold */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3871
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3872
	e1000_reset(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3873
	E1000_WRITE_REG(&adapter->hw, WUS, ~0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3874
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3875
	if(adapter->ecdev || netif_running(netdev))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3876
		e1000_up(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3877
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3878
	if (!adapter->ecdev) netif_device_attach(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3879
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3880
	if(adapter->hw.mac_type >= e1000_82540 &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3881
	   adapter->hw.media_type == e1000_media_type_copper) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3882
		manc = E1000_READ_REG(&adapter->hw, MANC);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3883
		manc &= ~(E1000_MANC_ARP_EN);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3884
		E1000_WRITE_REG(&adapter->hw, MANC, manc);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3885
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3886
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3887
	switch(adapter->hw.mac_type) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3888
	case e1000_82573:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3889
		swsm = E1000_READ_REG(&adapter->hw, SWSM);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3890
		E1000_WRITE_REG(&adapter->hw, SWSM,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3891
				swsm | E1000_SWSM_DRV_LOAD);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3892
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3893
	default:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3894
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3895
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3896
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3897
	return 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3898
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3899
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3900
#ifdef CONFIG_NET_POLL_CONTROLLER
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3901
/*
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3902
 * Polling 'interrupt' - used by things like netconsole to send skbs
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3903
 * without having to re-enable interrupts. It's not called while
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3904
 * the interrupt routine is executing.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3905
 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3906
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3907
e1000_netpoll(struct net_device *netdev)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3908
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3909
	struct e1000_adapter *adapter = netdev_priv(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3910
	disable_irq(adapter->pdev->irq);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3911
	e1000_intr(adapter->pdev->irq, netdev, NULL);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3912
	e1000_clean_tx_irq(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3913
	enable_irq(adapter->pdev->irq);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3914
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3915
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3916
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3917
/* e1000_main.c */