devices/e1000/e1000_main-2.6.13-ethercat.c
author Florian Pose <fp@igh-essen.com>
Wed, 23 Jul 2008 08:06:10 +0000
changeset 1136 a0982873d655
parent 1011 a0759d0dded4
child 1152 30f168c7f74f
permissions -rw-r--r--
Improved exceptions and commandName usage.
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
724
f188f8a0cafd Include e1000_suspend() in #ifdef CONFIG_PM.
Florian Pose <fp@igh-essen.com>
parents: 677
diff changeset
   167
#ifdef CONFIG_PM
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   168
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
   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
1011
a0759d0dded4 Improved ecdev_offer().
Florian Pose <fp@igh-essen.com>
parents: 727
diff changeset
   716
	adapter->ecdev = ecdev_offer(netdev, ec_poll, THIS_MODULE);
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   717
	if (adapter->ecdev) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   718
		if (ecdev_open(adapter->ecdev)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   719
			ecdev_withdraw(adapter->ecdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   720
			goto err_register;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   721
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   722
	} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   723
		strcpy(netdev->name, "eth%d");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   724
		if ((err = register_netdev(netdev)))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   725
			goto err_register;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   726
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   727
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   728
	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
   729
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   730
	cards_found++;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   731
	return 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   732
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   733
err_register:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   734
err_sw_init:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   735
err_eeprom:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   736
	iounmap(adapter->hw.hw_addr);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   737
err_ioremap:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   738
	free_netdev(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   739
err_alloc_etherdev:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   740
	pci_release_regions(pdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   741
	return err;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   742
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   743
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   744
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   745
 * e1000_remove - Device Removal Routine
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   746
 * @pdev: PCI device information struct
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
 * 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
   749
 * 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
   750
 * 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
   751
 * memory.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   752
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   753
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   754
static void __devexit
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   755
e1000_remove(struct pci_dev *pdev)
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
	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
   758
	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
   759
	uint32_t manc, swsm;
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
	flush_scheduled_work();
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   762
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   763
	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
   764
	   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
   765
		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
   766
		if(manc & E1000_MANC_SMBUS_EN) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   767
			manc |= E1000_MANC_ARP_EN;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   768
			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
   769
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   770
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   771
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   772
	switch(adapter->hw.mac_type) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   773
	case e1000_82573:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   774
		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
   775
		E1000_WRITE_REG(&adapter->hw, SWSM,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   776
				swsm & ~E1000_SWSM_DRV_LOAD);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   777
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   778
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   779
	default:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   780
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   781
	}
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
	if (adapter->ecdev) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   784
		ecdev_close(adapter->ecdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   785
		ecdev_withdraw(adapter->ecdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   786
	} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   787
		unregister_netdev(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   788
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   789
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   790
	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
   791
		e1000_phy_hw_reset(&adapter->hw);
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
	iounmap(adapter->hw.hw_addr);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   794
	pci_release_regions(pdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   795
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   796
	free_netdev(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   797
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   798
	pci_disable_device(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
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
 * 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
   803
 * @adapter: board private structure to initialize
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
 * 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
   806
 * 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
   807
 * OS network device settings (MTU size).
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
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   810
static int __devinit
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   811
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
   812
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   813
	struct e1000_hw *hw = &adapter->hw;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   814
	struct net_device *netdev = adapter->netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   815
	struct pci_dev *pdev = adapter->pdev;
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
	/* PCI config space info */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   818
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   819
	hw->vendor_id = pdev->vendor;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   820
	hw->device_id = pdev->device;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   821
	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
   822
	hw->subsystem_id = pdev->subsystem_device;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   823
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   824
	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
   825
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   826
	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
   827
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   828
	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
   829
	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
   830
	hw->max_frame_size = netdev->mtu +
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   831
			     ENET_HEADER_SIZE + ETHERNET_FCS_SIZE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   832
	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
   833
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   834
	/* identify the MAC */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   835
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   836
	if(e1000_set_mac_type(hw)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   837
		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
   838
		return -EIO;
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
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   841
	/* initialize eeprom parameters */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   842
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   843
	if(e1000_init_eeprom_params(hw)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   844
		E1000_ERR("EEPROM initialization failed\n");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   845
		return -EIO;
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
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   848
	switch(hw->mac_type) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   849
	default:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   850
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   851
	case e1000_82541:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   852
	case e1000_82547:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   853
	case e1000_82541_rev_2:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   854
	case e1000_82547_rev_2:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   855
		hw->phy_init_script = 1;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   856
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   857
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   858
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   859
	e1000_set_media_type(hw);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   860
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   861
	hw->wait_autoneg_complete = FALSE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   862
	hw->tbi_compatibility_en = TRUE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   863
	hw->adaptive_ifs = TRUE;
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
	/* Copper options */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   866
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   867
	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
   868
		hw->mdix = AUTO_ALL_MODES;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   869
		hw->disable_polarity_correction = FALSE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   870
		hw->master_slave = E1000_MASTER_SLAVE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   871
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   872
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   873
	atomic_set(&adapter->irq_sem, 1);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   874
	spin_lock_init(&adapter->stats_lock);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   875
	spin_lock_init(&adapter->tx_lock);
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
	return 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   878
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   879
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
 * 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
   882
 * @netdev: network interface device structure
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
 * 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
   885
 *
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   886
 * 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
   887
 * 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
   888
 * 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
   889
 * 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
   890
 * 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
   891
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   892
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   893
static int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   894
e1000_open(struct net_device *netdev)
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
	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
   897
	int err;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   898
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   899
	/* allocate transmit descriptors */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   900
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   901
	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
   902
		goto err_setup_tx;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   903
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   904
	/* allocate receive descriptors */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   905
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   906
	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
   907
		goto err_setup_rx;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   908
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   909
	if((err = e1000_up(adapter)))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   910
		goto err_up;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   911
	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
   912
	if((adapter->hw.mng_cookie.status &
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   913
			  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
   914
		e1000_update_mng_vlan(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   915
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   916
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   917
	return E1000_SUCCESS;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   918
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   919
err_up:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   920
	e1000_free_rx_resources(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   921
err_setup_rx:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   922
	e1000_free_tx_resources(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   923
err_setup_tx:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   924
	e1000_reset(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   925
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   926
	return err;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   927
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   928
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
 * e1000_close - Disables a network interface
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   931
 * @netdev: network interface device structure
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
 * 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
   934
 *
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   935
 * 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
   936
 * 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
   937
 * 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
   938
 * 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
   939
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   940
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   941
static int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   942
e1000_close(struct net_device *netdev)
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
	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
   945
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   946
	e1000_down(adapter);
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
	e1000_free_tx_resources(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   949
	e1000_free_rx_resources(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   950
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   951
	if((adapter->hw.mng_cookie.status &
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   952
			  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
   953
		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
   954
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   955
	return 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   956
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   957
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
 * 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
   960
 * @adapter: address of board private structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   961
 * @start: address of beginning of memory
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   962
 * @len: length of memory
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   963
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   964
static inline boolean_t
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   965
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
   966
		      void *start, unsigned long len)
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
	unsigned long begin = (unsigned long) start;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   969
	unsigned long end = begin + len;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   970
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   971
	/* 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
   972
	 * 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
   973
	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
   974
	    adapter->hw.mac_type == e1000_82546) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   975
		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
   976
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   977
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   978
	return TRUE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   979
}
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
 * 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
   983
 * @adapter: board private structure
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
 * 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
   986
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   987
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   988
int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   989
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
   990
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   991
	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
   992
	struct pci_dev *pdev = adapter->pdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   993
	int size;
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
	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
   996
	txdr->buffer_info = vmalloc(size);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   997
	if(!txdr->buffer_info) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   998
		DPRINTK(PROBE, ERR,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   999
		"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
  1000
		return -ENOMEM;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1001
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1002
	memset(txdr->buffer_info, 0, size);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1003
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1004
	/* round up to nearest 4K */
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
	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
  1007
	E1000_ROUNDUP(txdr->size, 4096);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1008
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1009
	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
  1010
	if(!txdr->desc) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1011
setup_tx_desc_die:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1012
		vfree(txdr->buffer_info);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1013
		DPRINTK(PROBE, ERR,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1014
		"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
  1015
		return -ENOMEM;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1016
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1017
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1018
	/* 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
  1019
	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
  1020
		void *olddesc = txdr->desc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1021
		dma_addr_t olddma = txdr->dma;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1022
		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
  1023
				     "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
  1024
		/* Try again, without freeing the previous */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1025
		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
  1026
		if(!txdr->desc) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1027
		/* Failed allocation, critical failure */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1028
			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
  1029
			goto setup_tx_desc_die;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1030
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1031
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1032
		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
  1033
			/* give up */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1034
			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
  1035
					    txdr->dma);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1036
			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
  1037
			DPRINTK(PROBE, ERR,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1038
				"Unable to allocate aligned memory "
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1039
				"for the transmit descriptor ring\n");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1040
			vfree(txdr->buffer_info);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1041
			return -ENOMEM;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1042
		} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1043
			/* 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
  1044
			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
  1045
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1046
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1047
	memset(txdr->desc, 0, txdr->size);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1048
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1049
	txdr->next_to_use = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1050
	txdr->next_to_clean = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1051
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1052
	return 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1053
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1054
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
 * 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
  1057
 * @adapter: board private structure
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
 * 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
  1060
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1061
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1062
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1063
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
  1064
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1065
	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
  1066
	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
  1067
	uint32_t tctl, tipg;
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
	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
  1070
	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
  1071
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1072
	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
  1073
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1074
	/* 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
  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, TDH, 0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1077
	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
  1078
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1079
	/* 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
  1080
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1081
	switch (adapter->hw.mac_type) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1082
	case e1000_82542_rev2_0:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1083
	case e1000_82542_rev2_1:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1084
		tipg = DEFAULT_82542_TIPG_IPGT;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1085
		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
  1086
		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
  1087
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1088
	default:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1089
		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
  1090
		   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
  1091
			tipg = DEFAULT_82543_TIPG_IPGT_FIBER;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1092
		else
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1093
			tipg = DEFAULT_82543_TIPG_IPGT_COPPER;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1094
		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
  1095
		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
  1096
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1097
	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
  1098
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1099
	/* Set the Tx Interrupt Delay register */
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, TIDV, adapter->tx_int_delay);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1102
	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
  1103
		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
  1104
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1105
	/* Program the Transmit Control Register */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1106
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1107
	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
  1108
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1109
	tctl &= ~E1000_TCTL_CT;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1110
	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
  1111
		(E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT);
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
	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
  1114
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1115
	e1000_config_collision_dist(&adapter->hw);
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
	/* 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
  1118
	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
  1119
		E1000_TXD_CMD_IFCS;
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
	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
  1122
		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
  1123
	else
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1124
		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
  1125
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1126
	/* 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
  1127
	 * 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
  1128
	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
  1129
	   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
  1130
		adapter->pcix_82544 = 1;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1131
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1132
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1133
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1134
 * 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
  1135
 * @adapter: board private structure
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
 * 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
  1138
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1139
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1140
int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1141
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
  1142
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1143
	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
  1144
	struct pci_dev *pdev = adapter->pdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1145
	int size, desc_len;
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
	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
  1148
	rxdr->buffer_info = vmalloc(size);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1149
	if(!rxdr->buffer_info) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1150
		DPRINTK(PROBE, ERR,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1151
		"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
  1152
		return -ENOMEM;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1153
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1154
	memset(rxdr->buffer_info, 0, size);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1155
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1156
	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
  1157
	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
  1158
	if(!rxdr->ps_page) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1159
		vfree(rxdr->buffer_info);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1160
		DPRINTK(PROBE, ERR,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1161
		"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
  1162
		return -ENOMEM;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1163
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1164
	memset(rxdr->ps_page, 0, size);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1165
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1166
	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
  1167
	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
  1168
	if(!rxdr->ps_page_dma) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1169
		vfree(rxdr->buffer_info);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1170
		kfree(rxdr->ps_page);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1171
		DPRINTK(PROBE, ERR,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1172
		"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
  1173
		return -ENOMEM;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1174
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1175
	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
  1176
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1177
	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
  1178
		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
  1179
	else
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1180
		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
  1181
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1182
	/* Round up to nearest 4K */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1183
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1184
	rxdr->size = rxdr->count * desc_len;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1185
	E1000_ROUNDUP(rxdr->size, 4096);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1186
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1187
	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
  1188
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1189
	if(!rxdr->desc) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1190
setup_rx_desc_die:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1191
		vfree(rxdr->buffer_info);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1192
		kfree(rxdr->ps_page);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1193
		kfree(rxdr->ps_page_dma);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1194
		DPRINTK(PROBE, ERR,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1195
		"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
  1196
		return -ENOMEM;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1197
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1198
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1199
	/* 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
  1200
	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
  1201
		void *olddesc = rxdr->desc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1202
		dma_addr_t olddma = rxdr->dma;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1203
		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
  1204
				     "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
  1205
		/* Try again, without freeing the previous */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1206
		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
  1207
		if(!rxdr->desc) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1208
		/* Failed allocation, critical failure */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1209
			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
  1210
			goto setup_rx_desc_die;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1211
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1212
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1213
		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
  1214
			/* give up */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1215
			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
  1216
					    rxdr->dma);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1217
			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
  1218
			DPRINTK(PROBE, ERR,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1219
				"Unable to allocate aligned memory "
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1220
				"for the receive descriptor ring\n");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1221
			vfree(rxdr->buffer_info);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1222
			kfree(rxdr->ps_page);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1223
			kfree(rxdr->ps_page_dma);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1224
			return -ENOMEM;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1225
		} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1226
			/* 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
  1227
			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
  1228
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1229
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1230
	memset(rxdr->desc, 0, rxdr->size);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1231
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1232
	rxdr->next_to_clean = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1233
	rxdr->next_to_use = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1234
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1235
	return 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1236
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1237
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
 * 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
  1240
 * @adapter: Board private structure
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
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1244
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
  1245
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1246
	uint32_t rctl, rfctl;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1247
	uint32_t psrctl = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1248
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1249
	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
  1250
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1251
	rctl &= ~(3 << E1000_RCTL_MO_SHIFT);
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_RCTL_EN | E1000_RCTL_BAM |
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1254
		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
  1255
		(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
  1256
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1257
	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
  1258
		rctl |= E1000_RCTL_SBP;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1259
	else
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1260
		rctl &= ~E1000_RCTL_SBP;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1261
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1262
	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
  1263
		rctl &= ~E1000_RCTL_LPE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1264
	else
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1265
		rctl |= E1000_RCTL_LPE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1266
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1267
	/* Setup buffer sizes */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1268
	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
  1269
		/* 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
  1270
		 * 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
  1271
		rctl |= adapter->rx_buffer_len << 0x11;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1272
	} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1273
		rctl &= ~E1000_RCTL_SZ_4096;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1274
		rctl |= E1000_RCTL_BSEX; 
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1275
		switch (adapter->rx_buffer_len) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1276
		case E1000_RXBUFFER_2048:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1277
		default:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1278
			rctl |= E1000_RCTL_SZ_2048;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1279
			rctl &= ~E1000_RCTL_BSEX;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1280
			break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1281
		case E1000_RXBUFFER_4096:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1282
			rctl |= E1000_RCTL_SZ_4096;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1283
			break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1284
		case E1000_RXBUFFER_8192:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1285
			rctl |= E1000_RCTL_SZ_8192;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1286
			break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1287
		case E1000_RXBUFFER_16384:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1288
			rctl |= E1000_RCTL_SZ_16384;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1289
			break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1290
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1291
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1292
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1293
#ifdef CONFIG_E1000_PACKET_SPLIT
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1294
	/* 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
  1295
	 * 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
  1296
	 * 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
  1297
	 * 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
  1298
	 * 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
  1299
	 * 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
  1300
	 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1301
	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
  1302
			  && (adapter->netdev->mtu 
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1303
	                      < ((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
  1304
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1305
	if(adapter->rx_ps) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1306
		/* Configure extra packet-split registers */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1307
		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
  1308
		rfctl |= E1000_RFCTL_EXTEN;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1309
		/* disable IPv6 packet split support */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1310
		rfctl |= E1000_RFCTL_IPV6_DIS;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1311
		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
  1312
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1313
		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
  1314
		
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1315
		psrctl |= adapter->rx_ps_bsize0 >>
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1316
			E1000_PSRCTL_BSIZE0_SHIFT;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1317
		psrctl |= PAGE_SIZE >>
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1318
			E1000_PSRCTL_BSIZE1_SHIFT;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1319
		psrctl |= PAGE_SIZE <<
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1320
			E1000_PSRCTL_BSIZE2_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_BSIZE3_SHIFT;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1323
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1324
		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
  1325
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1326
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1327
	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
  1328
}
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_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
  1332
 * @adapter: board private structure
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
 * 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
  1335
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1336
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1337
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1338
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
  1339
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1340
	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
  1341
	uint32_t rdlen, rctl, rxcsum;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1342
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1343
	if(adapter->rx_ps) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1344
		rdlen = adapter->rx_ring.count *
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1345
			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
  1346
		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
  1347
		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
  1348
	} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1349
		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
  1350
		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
  1351
		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
  1352
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1353
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1354
	/* 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
  1355
	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
  1356
	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
  1357
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1358
	/* set the Receive Delay Timer Register */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1359
	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
  1360
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1361
	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
  1362
		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
  1363
		if(adapter->itr > 1)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1364
			E1000_WRITE_REG(&adapter->hw, ITR,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1365
				1000000000 / (adapter->itr * 256));
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1366
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1367
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1368
	/* 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
  1369
	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
  1370
	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
  1371
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1372
	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
  1373
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1374
	/* 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
  1375
	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
  1376
	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
  1377
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1378
	/* 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
  1379
	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
  1380
		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
  1381
		if(adapter->rx_csum == TRUE) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1382
			rxcsum |= E1000_RXCSUM_TUOFL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1383
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1384
			/* 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
  1385
			 * 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
  1386
			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
  1387
			   (adapter->rx_ps)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1388
				rxcsum |= E1000_RXCSUM_IPPCSE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1389
			}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1390
		} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1391
			rxcsum &= ~E1000_RXCSUM_TUOFL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1392
			/* 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
  1393
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1394
		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
  1395
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1396
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1397
	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
  1398
		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
  1399
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1400
	/* Enable Receives */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1401
	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
  1402
}
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
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1405
 * 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
  1406
 * @adapter: board private structure
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
 * Free all transmit software resources
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1409
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1410
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1411
void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1412
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
  1413
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1414
	struct pci_dev *pdev = adapter->pdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1415
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1416
	e1000_clean_tx_ring(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
	vfree(adapter->tx_ring.buffer_info);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1419
	adapter->tx_ring.buffer_info = NULL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1420
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1421
	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
  1422
	                    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
  1423
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1424
	adapter->tx_ring.desc = NULL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1425
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1426
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1427
static inline void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1428
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
  1429
			struct e1000_buffer *buffer_info)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1430
{
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  1431
	if (adapter->ecdev)
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  1432
		return;
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  1433
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1434
	if(buffer_info->dma) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1435
		pci_unmap_page(adapter->pdev,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1436
				buffer_info->dma,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1437
				buffer_info->length,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1438
				PCI_DMA_TODEVICE);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1439
		buffer_info->dma = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1440
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1441
	if(buffer_info->skb) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1442
		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
  1443
		buffer_info->skb = NULL;
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
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1446
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1447
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1448
 * 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
  1449
 * @adapter: board private structure
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
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1453
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
  1454
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1455
	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
  1456
	struct e1000_buffer *buffer_info;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1457
	unsigned long size;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1458
	unsigned int i;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1459
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1460
	/* 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
  1461
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1462
	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
  1463
		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
  1464
				&adapter->previous_buffer_info);
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
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1467
	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
  1468
		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
  1469
		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
  1470
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1471
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1472
	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
  1473
	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
  1474
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1475
	/* Zero out the descriptor ring */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1476
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1477
	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
  1478
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1479
	tx_ring->next_to_use = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1480
	tx_ring->next_to_clean = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1481
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1482
	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
  1483
	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
  1484
}
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
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1487
 * 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
  1488
 * @adapter: board private structure
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
 * Free all receive software resources
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1491
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1492
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1493
void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1494
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
  1495
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1496
	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
  1497
	struct pci_dev *pdev = adapter->pdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1498
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1499
	e1000_clean_rx_ring(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1500
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1501
	vfree(rx_ring->buffer_info);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1502
	rx_ring->buffer_info = NULL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1503
	kfree(rx_ring->ps_page);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1504
	rx_ring->ps_page = NULL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1505
	kfree(rx_ring->ps_page_dma);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1506
	rx_ring->ps_page_dma = NULL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1507
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1508
	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
  1509
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1510
	rx_ring->desc = 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
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
 * 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
  1515
 * @adapter: board private structure
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
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1519
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
  1520
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1521
	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
  1522
	struct e1000_buffer *buffer_info;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1523
	struct e1000_ps_page *ps_page;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1524
	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
  1525
	struct pci_dev *pdev = adapter->pdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1526
	unsigned long size;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1527
	unsigned int i, j;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1528
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1529
	/* 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
  1530
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1531
	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
  1532
		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
  1533
		if(buffer_info->skb) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1534
			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
  1535
			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
  1536
			pci_unmap_single(pdev,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1537
					 buffer_info->dma,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1538
					 buffer_info->length,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1539
					 PCI_DMA_FROMDEVICE);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1540
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1541
			dev_kfree_skb(buffer_info->skb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1542
			buffer_info->skb = NULL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1543
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1544
			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
  1545
				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
  1546
				pci_unmap_single(pdev,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1547
						 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
  1548
						 PAGE_SIZE, PCI_DMA_FROMDEVICE);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1549
				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
  1550
				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
  1551
				ps_page->ps_page[j] = NULL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1552
			}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1553
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1554
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1555
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1556
	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
  1557
	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
  1558
	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
  1559
	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
  1560
	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
  1561
	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
  1562
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1563
	/* Zero out the descriptor ring */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1564
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1565
	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
  1566
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1567
	rx_ring->next_to_clean = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1568
	rx_ring->next_to_use = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1569
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1570
	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
  1571
	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
  1572
}
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
/* 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
  1575
 * 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
  1576
 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1577
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1578
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
  1579
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1580
	struct net_device *netdev = adapter->netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1581
	uint32_t rctl;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1582
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1583
	e1000_pci_clear_mwi(&adapter->hw);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1584
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1585
	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
  1586
	rctl |= E1000_RCTL_RST;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1587
	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
  1588
	E1000_WRITE_FLUSH(&adapter->hw);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1589
	mdelay(5);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1590
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1591
	if (!adapter->ecdev && netif_running(netdev))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1592
		e1000_clean_rx_ring(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1593
}
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
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1596
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
  1597
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1598
	struct net_device *netdev = adapter->netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1599
	uint32_t rctl;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1600
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1601
	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
  1602
	rctl &= ~E1000_RCTL_RST;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1603
	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
  1604
	E1000_WRITE_FLUSH(&adapter->hw);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1605
	mdelay(5);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1606
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1607
	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
  1608
		e1000_pci_set_mwi(&adapter->hw);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1609
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1610
	if (!adapter->ecdev && netif_running(netdev)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1611
		e1000_configure_rx(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1612
		e1000_alloc_rx_buffers(adapter);
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
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1615
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1616
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1617
 * 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
  1618
 * @netdev: network interface device structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1619
 * @p: pointer to an address structure
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
 * 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
  1622
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1623
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1624
static int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1625
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
  1626
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1627
	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
  1628
	struct sockaddr *addr = p;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1629
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1630
	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
  1631
		return -EADDRNOTAVAIL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1632
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1633
	/* 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
  1634
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1635
	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
  1636
		e1000_enter_82542_rst(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1637
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1638
	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
  1639
	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
  1640
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1641
	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
  1642
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1643
	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
  1644
		e1000_leave_82542_rst(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1645
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1646
	return 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1647
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1648
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
 * 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
  1651
 * @netdev: network interface device structure
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
 * 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
  1654
 * 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
  1655
 * 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
  1656
 * promiscuous mode, and all-multi behavior.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1657
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1658
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1659
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1660
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
  1661
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1662
	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
  1663
	struct e1000_hw *hw = &adapter->hw;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1664
	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
  1665
	unsigned long flags = 0;
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1666
	uint32_t rctl;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1667
	uint32_t hash_value;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1668
	int i;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1669
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  1670
    if (!adapter->ecdev)
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  1671
        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
  1672
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1673
	/* 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
  1674
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1675
	rctl = E1000_READ_REG(hw, RCTL);
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
	if(netdev->flags & IFF_PROMISC) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1678
		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
  1679
	} else if(netdev->flags & IFF_ALLMULTI) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1680
		rctl |= E1000_RCTL_MPE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1681
		rctl &= ~E1000_RCTL_UPE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1682
	} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1683
		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
  1684
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1685
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1686
	E1000_WRITE_REG(hw, RCTL, rctl);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1687
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1688
	/* 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
  1689
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1690
	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
  1691
		e1000_enter_82542_rst(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1692
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1693
	/* 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
  1694
	 * 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
  1695
	 * 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
  1696
	 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1697
	mc_ptr = netdev->mc_list;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1698
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1699
	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
  1700
		if(mc_ptr) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1701
			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
  1702
			mc_ptr = mc_ptr->next;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1703
		} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1704
			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
  1705
			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
  1706
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1707
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1708
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1709
	/* 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
  1710
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1711
	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
  1712
		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
  1713
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1714
	/* 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
  1715
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1716
	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
  1717
		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
  1718
		e1000_mta_set(hw, hash_value);
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
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1721
	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
  1722
		e1000_leave_82542_rst(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1723
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  1724
    if (!adapter->ecdev)
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  1725
        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
  1726
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1727
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1728
/* 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
  1729
 * the phy */
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
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1732
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
  1733
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1734
	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
  1735
	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
  1736
}
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
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1739
 * 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
  1740
 * @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
  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
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1744
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
  1745
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1746
	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
  1747
	struct net_device *netdev = adapter->netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1748
	uint32_t tctl;
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
	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
  1751
		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
  1752
		    E1000_READ_REG(&adapter->hw, TDH)) &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1753
		   (E1000_READ_REG(&adapter->hw, TDFT) ==
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1754
		    E1000_READ_REG(&adapter->hw, TDFH)) &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1755
		   (E1000_READ_REG(&adapter->hw, TDFTS) ==
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1756
		    E1000_READ_REG(&adapter->hw, TDFHS))) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1757
			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
  1758
			E1000_WRITE_REG(&adapter->hw, TCTL,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1759
					tctl & ~E1000_TCTL_EN);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1760
			E1000_WRITE_REG(&adapter->hw, TDFT,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1761
					adapter->tx_head_addr);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1762
			E1000_WRITE_REG(&adapter->hw, TDFH,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1763
					adapter->tx_head_addr);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1764
			E1000_WRITE_REG(&adapter->hw, TDFTS,
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, TDFHS,
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, TCTL, tctl);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1769
			E1000_WRITE_FLUSH(&adapter->hw);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1770
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1771
			adapter->tx_fifo_head = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1772
			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
  1773
			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
  1774
		} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1775
			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
  1776
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1777
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1778
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1779
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
 * e1000_watchdog - Timer Call-back
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1782
 * @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
  1783
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1784
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1785
e1000_watchdog(unsigned long data)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1786
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1787
	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
  1788
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1789
	/* 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
  1790
	schedule_work(&adapter->watchdog_task);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1791
}
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
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1794
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
  1795
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1796
	struct net_device *netdev = adapter->netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1797
	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
  1798
	uint32_t link;
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
	e1000_check_for_link(&adapter->hw);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1801
	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
  1802
		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
  1803
		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
  1804
			e1000_update_mng_vlan(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1805
	}	
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1806
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1807
	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
  1808
	   !(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
  1809
		link = !adapter->hw.serdes_link_down;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1810
	else
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1811
		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
  1812
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1813
	if (link) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1814
		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
  1815
				|| (!adapter->ecdev && !netif_carrier_ok(netdev))) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1816
			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
  1817
			                           &adapter->link_speed,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1818
			                           &adapter->link_duplex);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1819
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1820
			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
  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 == FULL_DUPLEX ?
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1823
			       "Full Duplex" : "Half Duplex");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1824
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1825
			if (adapter->ecdev) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1826
				ecdev_set_link(adapter->ecdev, 1);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1827
			} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1828
				netif_carrier_on(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1829
				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
  1830
                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
  1831
			}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1832
			adapter->smartspeed = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1833
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1834
	} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1835
		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
  1836
				|| (!adapter->ecdev && netif_carrier_ok(netdev))) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1837
			adapter->link_speed = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1838
			adapter->link_duplex = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1839
			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
  1840
			if (adapter->ecdev) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1841
				ecdev_set_link(adapter->ecdev, 0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1842
			} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1843
				netif_carrier_off(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1844
				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
  1845
                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
  1846
			}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1847
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1848
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1849
		e1000_smartspeed(adapter);
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
	e1000_update_stats(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1853
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1854
	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
  1855
	adapter->tpt_old = adapter->stats.tpt;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1856
	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
  1857
	adapter->colc_old = adapter->stats.colc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1858
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1859
	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
  1860
	adapter->gorcl_old = adapter->stats.gorcl;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1861
	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
  1862
	adapter->gotcl_old = adapter->stats.gotcl;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1863
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1864
	e1000_update_adaptive(&adapter->hw);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1865
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  1866
	if (!adapter->ecdev && !netif_carrier_ok(netdev)) {
677
7c7cf2d6c911 Minor changes.
Florian Pose <fp@igh-essen.com>
parents: 676
diff changeset
  1867
		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
  1868
			/* 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
  1869
			 * 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
  1870
			 * 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
  1871
			 * (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
  1872
			schedule_work(&adapter->tx_timeout_task);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1873
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1874
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1875
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1876
	/* 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
  1877
	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
  1878
		/* 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
  1879
		 * 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
  1880
		 * else is between 2000-8000. */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1881
		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
  1882
		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
  1883
			adapter->gotcl - adapter->gorcl :
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1884
			adapter->gorcl - adapter->gotcl) / 10000;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1885
		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
  1886
		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
  1887
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1888
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1889
	/* 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
  1890
	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
  1891
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1892
	/* 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
  1893
	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
  1894
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1895
	/* 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
  1896
	if (!adapter->ecdev)
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  1897
        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
  1898
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1899
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1900
#define E1000_TX_FLAGS_CSUM		0x00000001
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1901
#define E1000_TX_FLAGS_VLAN		0x00000002
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1902
#define E1000_TX_FLAGS_TSO		0x00000004
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1903
#define E1000_TX_FLAGS_IPV4		0x00000008
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1904
#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
  1905
#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
  1906
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1907
static inline int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1908
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
  1909
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1910
#ifdef NETIF_F_TSO
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1911
	struct e1000_context_desc *context_desc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1912
	unsigned int i;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1913
	uint32_t cmd_length = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1914
	uint16_t ipcse = 0, tucse, mss;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1915
	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
  1916
	int err;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1917
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1918
	if(skb_shinfo(skb)->tso_size) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1919
		if (skb_header_cloned(skb)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1920
			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
  1921
			if (err)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1922
				return err;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1923
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1924
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1925
		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
  1926
		mss = skb_shinfo(skb)->tso_size;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1927
		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
  1928
			skb->nh.iph->tot_len = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1929
			skb->nh.iph->check = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1930
			skb->h.th->check =
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1931
				~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
  1932
						   skb->nh.iph->daddr,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1933
						   0,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1934
						   IPPROTO_TCP,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1935
						   0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1936
			cmd_length = E1000_TXD_CMD_IP;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1937
			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
  1938
#ifdef NETIF_F_TSO_IPV6
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1939
		} 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
  1940
			skb->nh.ipv6h->payload_len = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1941
			skb->h.th->check =
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1942
				~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
  1943
						 &skb->nh.ipv6h->daddr,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1944
						 0,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1945
						 IPPROTO_TCP,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1946
						 0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1947
			ipcse = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1948
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1949
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1950
		ipcss = skb->nh.raw - skb->data;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1951
		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
  1952
		tucss = skb->h.raw - skb->data;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1953
		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
  1954
		tucse = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1955
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1956
		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
  1957
			       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
  1958
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1959
		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
  1960
		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
  1961
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1962
		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
  1963
		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
  1964
		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
  1965
		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
  1966
		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
  1967
		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
  1968
		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
  1969
		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
  1970
		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
  1971
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1972
		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
  1973
		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
  1974
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1975
		return 1;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1976
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1977
#endif
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 0;
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
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1982
static inline boolean_t
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1983
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
  1984
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1985
	struct e1000_context_desc *context_desc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1986
	unsigned int i;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1987
	uint8_t css;
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
	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
  1990
		css = skb->h.raw - skb->data;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1991
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1992
		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
  1993
		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
  1994
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1995
		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
  1996
		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
  1997
		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
  1998
		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
  1999
		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
  2000
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2001
		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
  2002
		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
  2003
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2004
		return TRUE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2005
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2006
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2007
	return FALSE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2008
}
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
#define E1000_MAX_TXD_PWR	12
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2011
#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
  2012
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2013
static inline int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2014
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
  2015
	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
  2016
	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
  2017
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2018
	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
  2019
	struct e1000_buffer *buffer_info;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2020
	unsigned int len = skb->len;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2021
	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
  2022
	unsigned int f;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2023
	len -= skb->data_len;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2024
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2025
	i = tx_ring->next_to_use;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2026
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2027
	while(len) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2028
		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
  2029
		size = min(len, max_per_txd);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2030
#ifdef NETIF_F_TSO
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2031
		/* Workaround for premature desc write-backs
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2032
		 * 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
  2033
		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
  2034
			size -= 4;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2035
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2036
		/* 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
  2037
		 * 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
  2038
		 * 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
  2039
		 * 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
  2040
		 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2041
		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
  2042
		                (size > 2015) && count == 0))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2043
		        size = 2015;
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
		/* 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
  2046
		 * terminating buffers within evenly-aligned dwords. */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2047
		if(unlikely(adapter->pcix_82544 &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2048
		   !((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
  2049
		   size > 4))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2050
			size -= 4;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2051
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2052
		buffer_info->length = size;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2053
		buffer_info->dma =
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2054
			pci_map_single(adapter->pdev,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2055
				skb->data + offset,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2056
				size,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2057
				PCI_DMA_TODEVICE);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2058
		buffer_info->time_stamp = jiffies;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2059
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2060
		len -= size;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2061
		offset += size;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2062
		count++;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2063
		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
  2064
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2065
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2066
	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
  2067
		struct skb_frag_struct *frag;
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
		frag = &skb_shinfo(skb)->frags[f];
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2070
		len = frag->size;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2071
		offset = frag->page_offset;
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
		while(len) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2074
			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
  2075
			size = min(len, max_per_txd);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2076
#ifdef NETIF_F_TSO
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2077
			/* Workaround for premature desc write-backs
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2078
			 * 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
  2079
			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
  2080
				size -= 4;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2081
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2082
			/* 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
  2083
			 * Avoid terminating buffers within evenly-aligned
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2084
			 * dwords. */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2085
			if(unlikely(adapter->pcix_82544 &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2086
			   !((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
  2087
			   size > 4))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2088
				size -= 4;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2089
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2090
			buffer_info->length = size;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2091
			buffer_info->dma =
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2092
				pci_map_page(adapter->pdev,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2093
					frag->page,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2094
					offset,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2095
					size,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2096
					PCI_DMA_TODEVICE);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2097
			buffer_info->time_stamp = jiffies;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2098
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2099
			len -= size;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2100
			offset += size;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2101
			count++;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2102
			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
  2103
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2104
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2105
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2106
	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
  2107
	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
  2108
	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
  2109
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2110
	return count;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2111
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2112
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2113
static inline void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2114
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
  2115
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2116
	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
  2117
	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
  2118
	struct e1000_buffer *buffer_info;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2119
	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
  2120
	unsigned int i;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2121
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2122
	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
  2123
		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
  2124
		             E1000_TXD_CMD_TSE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2125
		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
  2126
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2127
		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
  2128
			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
  2129
	}
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_CSUM)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2132
		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
  2133
		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
  2134
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2135
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2136
	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
  2137
		txd_lower |= E1000_TXD_CMD_VLE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2138
		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
  2139
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2140
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2141
	i = tx_ring->next_to_use;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2142
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2143
	while(count--) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2144
		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
  2145
		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
  2146
		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
  2147
		tx_desc->lower.data =
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2148
			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
  2149
		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
  2150
		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
  2151
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2152
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2153
	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
  2154
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2155
	/* 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
  2156
	 * 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
  2157
	 * 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
  2158
	 * such as IA-64). */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2159
	wmb();
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2160
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2161
	tx_ring->next_to_use = i;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2162
	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
  2163
}
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
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2166
 * 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
  2167
 * 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
  2168
 * 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
  2169
 * 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
  2170
 * 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
  2171
 * 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
  2172
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2173
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2174
#define E1000_FIFO_HDR			0x10
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2175
#define E1000_82547_PAD_LEN		0x3E0
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
static inline int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2178
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
  2179
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2180
	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
  2181
	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
  2182
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2183
	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
  2184
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2185
	if(adapter->link_duplex != HALF_DUPLEX)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2186
		goto no_fifo_stall_required;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2187
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2188
	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
  2189
		return 1;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2190
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2191
	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
  2192
		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
  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
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2196
no_fifo_stall_required:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2197
	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
  2198
	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
  2199
		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
  2200
	return 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2201
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2202
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2203
#define MINIMUM_DHCP_PACKET_SIZE 282
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2204
static inline int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2205
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
  2206
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2207
	struct e1000_hw *hw =  &adapter->hw;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2208
	uint16_t length, offset;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2209
	if(vlan_tx_tag_present(skb)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2210
		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
  2211
			( adapter->hw.mng_cookie.status &
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2212
			  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
  2213
			return 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2214
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2215
	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
  2216
		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
  2217
		if(IPPROTO_UDP == ip->protocol) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2218
			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
  2219
			if(ntohs(udp->dest) == 67) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2220
				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
  2221
				length = skb->len - offset;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2222
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2223
				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
  2224
						(uint8_t *)udp + 8, length);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2225
			}
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
	} 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
  2228
		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
  2229
		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
  2230
			const struct iphdr *ip = 
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2231
				(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
  2232
			if(IPPROTO_UDP == ip->protocol) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2233
				struct udphdr *udp = 
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2234
					(struct udphdr *)((uint8_t *)ip + 
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2235
						(ip->ihl << 2));
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2236
				if(ntohs(udp->dest) == 67) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2237
					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
  2238
					length = skb->len - offset;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2239
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2240
					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
  2241
							(uint8_t *)udp + 8, 
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2242
							length);
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
			}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2245
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2246
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2247
	return 0;
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
#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
  2251
static int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2252
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
  2253
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2254
	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
  2255
	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
  2256
	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
  2257
	unsigned int tx_flags = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2258
	unsigned int len = skb->len;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2259
	unsigned long flags = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2260
	unsigned int nr_frags = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2261
	unsigned int mss = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2262
	int count = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2263
	int tso;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2264
	unsigned int f;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2265
	len -= skb->data_len;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2266
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2267
	if(unlikely(skb->len <= 0)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2268
		if (!adapter->ecdev)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2269
			dev_kfree_skb_any(skb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2270
		return NETDEV_TX_OK;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2271
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2272
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2273
#ifdef NETIF_F_TSO
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2274
	mss = skb_shinfo(skb)->tso_size;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2275
	/* 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
  2276
	 * 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
  2277
	 * 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
  2278
	 * 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
  2279
	 * 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
  2280
	 * drops. */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2281
	if(mss) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2282
		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
  2283
		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
  2284
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2285
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2286
	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
  2287
		count++;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2288
	count++;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2289
#else
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2290
	if(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
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2293
	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
  2294
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2295
	if(adapter->pcix_82544)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2296
		count++;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2297
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2298
	/* 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
  2299
	 * 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
  2300
	 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2301
	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
  2302
			(len > 2015)))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2303
		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
	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
  2306
	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
  2307
		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
  2308
				       max_txd_pwr);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2309
	if(adapter->pcix_82544)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2310
		count += nr_frags;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2311
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2312
	if (!adapter->ecdev) {
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2313
		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
  2314
		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
  2315
			/* 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
  2316
			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
  2317
			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
  2318
		} 
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2319
		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
  2320
			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
  2321
	}
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2322
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2323
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2324
	/* 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
  2325
	 * head, otherwise try next time */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2326
	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
  2327
		if (!adapter->ecdev) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2328
			netif_stop_queue(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2329
			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
  2330
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2331
		return NETDEV_TX_BUSY;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2332
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2333
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2334
	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
  2335
		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
  2336
			if (!adapter->ecdev) {
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2337
				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
  2338
                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
  2339
				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
  2340
            }
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2341
			return NETDEV_TX_BUSY;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2342
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2343
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2344
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2345
	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
  2346
		tx_flags |= E1000_TX_FLAGS_VLAN;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2347
		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
  2348
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2349
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2350
	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
  2351
	
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2352
	tso = e1000_tso(adapter, skb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2353
	if (tso < 0) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2354
		if (!adapter->ecdev) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2355
			dev_kfree_skb_any(skb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2356
			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
  2357
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2358
		return NETDEV_TX_OK;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2359
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2360
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2361
	if (likely(tso))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2362
		tx_flags |= E1000_TX_FLAGS_TSO;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2363
	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
  2364
		tx_flags |= E1000_TX_FLAGS_CSUM;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2365
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2366
	/* 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
  2367
	 * 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
  2368
	 * no longer assume, we must. */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2369
	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
  2370
		tx_flags |= E1000_TX_FLAGS_IPV4;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2371
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2372
	e1000_tx_queue(adapter,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2373
		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
  2374
		tx_flags);
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
	netdev->trans_start = jiffies;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2377
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2378
	/* 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
  2379
	if (!adapter->ecdev) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2380
		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
  2381
			netif_stop_queue(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2382
		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
  2383
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2384
	return NETDEV_TX_OK;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2385
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2386
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
 * 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
  2389
 * @netdev: network interface device structure
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
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2393
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
  2394
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2395
	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
  2396
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2397
	/* 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
  2398
	schedule_work(&adapter->tx_timeout_task);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2399
}
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
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2402
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
  2403
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2404
	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
  2405
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2406
	e1000_down(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2407
	e1000_up(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2408
}
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
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2411
 * 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
  2412
 * @netdev: network interface device structure
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
 * 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
  2415
 * 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
  2416
 **/
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
static struct net_device_stats *
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2419
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
  2420
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2421
	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
  2422
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2423
	e1000_update_stats(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2424
	return &adapter->net_stats;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2425
}
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
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2428
 * 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
  2429
 * @netdev: network interface device structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2430
 * @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
  2431
 *
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2432
 * 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
  2433
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2434
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2435
static int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2436
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
  2437
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2438
	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
  2439
	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
  2440
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2441
	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
  2442
		(max_frame > MAX_JUMBO_FRAME_SIZE)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2443
			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
  2444
			return -EINVAL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2445
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2446
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2447
#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
  2448
	/* 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
  2449
	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
  2450
	    max_frame > MAXIMUM_ETHERNET_FRAME_SIZE) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2451
		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
  2452
				    "on 82573\n");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2453
		return -EINVAL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2454
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2455
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2456
	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
  2457
		adapter->rx_buffer_len = max_frame;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2458
		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
  2459
	} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2460
		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
  2461
		   (max_frame > MAXIMUM_ETHERNET_FRAME_SIZE))) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2462
			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
  2463
					    "on 82542\n");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2464
			return -EINVAL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2465
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2466
		} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2467
			if(max_frame <= E1000_RXBUFFER_2048) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2468
				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
  2469
			} 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
  2470
				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
  2471
			} 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
  2472
				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
  2473
			} 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
  2474
				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
  2475
			}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2476
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2477
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2478
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2479
	netdev->mtu = new_mtu;
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
	if (adapter->ecdev || netif_running(netdev)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2482
		e1000_down(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2483
		e1000_up(adapter);
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
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2486
	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
  2487
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2488
	return 0;
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
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
 * 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
  2493
 * @adapter: board private structure
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
void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2497
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
  2498
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2499
	struct e1000_hw *hw = &adapter->hw;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2500
	unsigned long flags = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2501
	uint16_t phy_tmp;
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
#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
  2504
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2505
	if (!adapter->ecdev)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2506
		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
  2507
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2508
	/* 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
  2509
	 * 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
  2510
	 * 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
  2511
	 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2512
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2513
	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
  2514
	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
  2515
	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
  2516
	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
  2517
	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
  2518
	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
  2519
	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
  2520
	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
  2521
	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
  2522
	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
  2523
	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
  2524
	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
  2525
	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
  2526
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2527
	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
  2528
	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
  2529
	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
  2530
	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
  2531
	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
  2532
	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
  2533
	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
  2534
	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
  2535
	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
  2536
	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
  2537
	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
  2538
	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
  2539
	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
  2540
	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
  2541
	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
  2542
	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
  2543
	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
  2544
	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
  2545
	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
  2546
	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
  2547
	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
  2548
	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
  2549
	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
  2550
	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
  2551
	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
  2552
	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
  2553
	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
  2554
	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
  2555
	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
  2556
	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
  2557
	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
  2558
	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
  2559
	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
  2560
	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
  2561
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2562
	/* used for adaptive IFS */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2563
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2564
	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
  2565
	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
  2566
	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
  2567
	adapter->stats.colc += hw->collision_delta;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2568
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2569
	if(hw->mac_type >= e1000_82543) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2570
		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
  2571
		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
  2572
		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
  2573
		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
  2574
		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
  2575
		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
  2576
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2577
	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
  2578
		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
  2579
		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
  2580
		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
  2581
		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
  2582
		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
  2583
		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
  2584
		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
  2585
		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
  2586
		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
  2587
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2588
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2589
	/* Fill out the OS statistics structure */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2590
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2591
	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
  2592
	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
  2593
	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
  2594
	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
  2595
	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
  2596
	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
  2597
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2598
	/* Rx Errors */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2599
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2600
	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
  2601
		adapter->stats.crcerrs + adapter->stats.algnerrc +
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2602
		adapter->stats.rlec + adapter->stats.mpc + 
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2603
		adapter->stats.cexterr;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2604
	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
  2605
	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
  2606
	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
  2607
	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
  2608
	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
  2609
	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
  2610
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2611
	/* Tx Errors */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2612
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2613
	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
  2614
	                               adapter->stats.latecol;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2615
	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
  2616
	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
  2617
	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
  2618
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2619
	/* 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
  2620
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2621
	/* Phy Stats */
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
	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
  2624
		if((adapter->link_speed == SPEED_1000) &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2625
		   (!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
  2626
			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
  2627
			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
  2628
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2629
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2630
		if((hw->mac_type <= e1000_82546) &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2631
		   (hw->phy_type == e1000_phy_m88) &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2632
		   !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
  2633
			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
  2634
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2635
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2636
	if (!adapter->ecdev)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2637
		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
  2638
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2639
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2640
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
  2641
{
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2642
    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
  2643
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2644
    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
  2645
        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
  2646
        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
  2647
    }
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2648
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2649
    e1000_intr(0, netdev, NULL);
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2650
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2651
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2652
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2653
 * e1000_intr - Interrupt Handler
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2654
 * @irq: interrupt number
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2655
 * @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
  2656
 * @pt_regs: CPU registers structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2657
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2658
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2659
static irqreturn_t
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2660
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
  2661
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2662
	struct net_device *netdev = data;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2663
	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
  2664
	struct e1000_hw *hw = &adapter->hw;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2665
	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
  2666
	unsigned int i;
727
fc533d28c6f8 Fixed e1000 driver when NAPI is enabled.
Florian Pose <fp@igh-essen.com>
parents: 724
diff changeset
  2667
#ifdef CONFIG_E1000_NAPI
fc533d28c6f8 Fixed e1000 driver when NAPI is enabled.
Florian Pose <fp@igh-essen.com>
parents: 724
diff changeset
  2668
	int work_done = 0;
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2669
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2670
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2671
	if(unlikely(!icr))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2672
		return IRQ_NONE;  /* Not our interrupt */
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 & (E1000_ICR_RXSEQ | E1000_ICR_LSC))) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2675
		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
  2676
		if (!adapter->ecdev)
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2677
            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
  2678
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2679
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2680
#ifdef CONFIG_E1000_NAPI
727
fc533d28c6f8 Fixed e1000 driver when NAPI is enabled.
Florian Pose <fp@igh-essen.com>
parents: 724
diff changeset
  2681
	if (adapter->ecdev) {
fc533d28c6f8 Fixed e1000 driver when NAPI is enabled.
Florian Pose <fp@igh-essen.com>
parents: 724
diff changeset
  2682
		for(i = 0; i < E1000_MAX_INTR; i++)
fc533d28c6f8 Fixed e1000 driver when NAPI is enabled.
Florian Pose <fp@igh-essen.com>
parents: 724
diff changeset
  2683
			if(unlikely(!adapter->clean_rx(adapter, &work_done, 100) &
fc533d28c6f8 Fixed e1000 driver when NAPI is enabled.
Florian Pose <fp@igh-essen.com>
parents: 724
diff changeset
  2684
						!e1000_clean_tx_irq(adapter)))
fc533d28c6f8 Fixed e1000 driver when NAPI is enabled.
Florian Pose <fp@igh-essen.com>
parents: 724
diff changeset
  2685
				break;
fc533d28c6f8 Fixed e1000 driver when NAPI is enabled.
Florian Pose <fp@igh-essen.com>
parents: 724
diff changeset
  2686
	} else {
fc533d28c6f8 Fixed e1000 driver when NAPI is enabled.
Florian Pose <fp@igh-essen.com>
parents: 724
diff changeset
  2687
		if(likely(netif_rx_schedule_prep(netdev))) {
fc533d28c6f8 Fixed e1000 driver when NAPI is enabled.
Florian Pose <fp@igh-essen.com>
parents: 724
diff changeset
  2688
fc533d28c6f8 Fixed e1000 driver when NAPI is enabled.
Florian Pose <fp@igh-essen.com>
parents: 724
diff changeset
  2689
			/* Disable interrupts and register for poll. The flush 
fc533d28c6f8 Fixed e1000 driver when NAPI is enabled.
Florian Pose <fp@igh-essen.com>
parents: 724
diff changeset
  2690
			   of the posted write is intentionally left out.
fc533d28c6f8 Fixed e1000 driver when NAPI is enabled.
Florian Pose <fp@igh-essen.com>
parents: 724
diff changeset
  2691
			 */
fc533d28c6f8 Fixed e1000 driver when NAPI is enabled.
Florian Pose <fp@igh-essen.com>
parents: 724
diff changeset
  2692
fc533d28c6f8 Fixed e1000 driver when NAPI is enabled.
Florian Pose <fp@igh-essen.com>
parents: 724
diff changeset
  2693
			atomic_inc(&adapter->irq_sem);
fc533d28c6f8 Fixed e1000 driver when NAPI is enabled.
Florian Pose <fp@igh-essen.com>
parents: 724
diff changeset
  2694
			E1000_WRITE_REG(hw, IMC, ~0);
fc533d28c6f8 Fixed e1000 driver when NAPI is enabled.
Florian Pose <fp@igh-essen.com>
parents: 724
diff changeset
  2695
			__netif_rx_schedule(netdev);
fc533d28c6f8 Fixed e1000 driver when NAPI is enabled.
Florian Pose <fp@igh-essen.com>
parents: 724
diff changeset
  2696
		}
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2697
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2698
#else
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2699
	/* 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
  2700
	   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
  2701
	   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
  2702
	   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
  2703
	   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
  2704
	   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
  2705
	   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
  2706
	   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
  2707
	   de-assertion state.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2708
	*/
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2709
	if(!adapter->ecdev &&
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2710
			(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
  2711
		atomic_inc(&adapter->irq_sem);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2712
		E1000_WRITE_REG(hw, IMC, ~0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2713
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2714
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2715
	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
  2716
		if(unlikely(!adapter->clean_rx(adapter) &
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2717
		   !e1000_clean_tx_irq(adapter)))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2718
			break;
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
	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
  2721
		e1000_irq_enable(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2722
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2723
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2724
	return IRQ_HANDLED;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2725
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2726
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2727
#ifdef CONFIG_E1000_NAPI
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
 * e1000_clean - NAPI Rx polling callback
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2730
 * @adapter: board private structure
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
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2733
static int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2734
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
  2735
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2736
	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
  2737
	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
  2738
	int tx_cleaned;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2739
	int work_done = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2740
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2741
	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
  2742
	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
  2743
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2744
	*budget -= work_done;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2745
	netdev->quota -= work_done;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2746
	
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2747
	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
  2748
	/* 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
  2749
		netif_rx_complete(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2750
		e1000_irq_enable(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2751
		return 0;
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
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2754
	return 1;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2755
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2756
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2757
#endif
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
 * 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
  2760
 * @adapter: board private structure
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
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2763
static boolean_t
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2764
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
  2765
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2766
	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
  2767
	struct net_device *netdev = adapter->netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2768
	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
  2769
	struct e1000_buffer *buffer_info;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2770
	unsigned int i, eop;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2771
	boolean_t cleaned = FALSE;
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
	i = tx_ring->next_to_clean;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2774
	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
  2775
	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
  2776
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2777
	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
  2778
		/* 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
  2779
		 * 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
  2780
		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
  2781
			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
  2782
					&adapter->previous_buffer_info);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2783
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2784
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2785
		for(cleaned = FALSE; !cleaned; ) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2786
			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
  2787
			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
  2788
			cleaned = (i == eop);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2789
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2790
#ifdef NETIF_F_TSO
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2791
			if (!(netdev->features & NETIF_F_TSO)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2792
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2793
				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
  2794
				                                 buffer_info);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2795
#ifdef NETIF_F_TSO
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2796
			} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2797
				if (cleaned) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2798
					memcpy(&adapter->previous_buffer_info,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2799
					       buffer_info,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2800
					       sizeof(struct e1000_buffer));
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2801
					memset(buffer_info, 0,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2802
					       sizeof(struct e1000_buffer));
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2803
				} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2804
					e1000_unmap_and_free_tx_resource(
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2805
					    adapter, buffer_info);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2806
				}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2807
			}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2808
#endif
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
			tx_desc->buffer_addr = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2811
			tx_desc->lower.data = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2812
			tx_desc->upper.data = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2813
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2814
			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
  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
		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
  2818
		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
  2819
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2820
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2821
	tx_ring->next_to_clean = i;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2822
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2823
	if (!adapter->ecdev) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2824
		spin_lock(&adapter->tx_lock);
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
		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
  2827
					netif_carrier_ok(netdev)))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2828
			netif_wake_queue(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2829
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2830
		spin_unlock(&adapter->tx_lock);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2831
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2832
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2833
	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
  2834
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2835
		/* 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
  2836
		 * 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
  2837
		adapter->detect_tx_hung = FALSE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2838
		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
  2839
		    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
  2840
		    && !(E1000_READ_REG(&adapter->hw, STATUS) &
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2841
			E1000_STATUS_TXOFF)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2842
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2843
			/* detected Tx unit hang */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2844
			i = tx_ring->next_to_clean;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2845
			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
  2846
			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
  2847
			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
  2848
					"  TDH                  <%x>\n"
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2849
					"  TDT                  <%x>\n"
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2850
					"  next_to_use          <%x>\n"
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2851
					"  next_to_clean        <%x>\n"
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2852
					"buffer_info[next_to_clean]\n"
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2853
					"  dma                  <%zx>\n"
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2854
					"  time_stamp           <%lx>\n"
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2855
					"  next_to_watch        <%x>\n"
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2856
					"  jiffies              <%lx>\n"
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2857
					"  next_to_watch.status <%x>\n",
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2858
				E1000_READ_REG(&adapter->hw, TDH),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2859
				E1000_READ_REG(&adapter->hw, TDT),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2860
				tx_ring->next_to_use,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2861
				i,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2862
				tx_ring->buffer_info[i].dma,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2863
				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
  2864
				eop,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2865
				jiffies,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2866
				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
  2867
			netif_stop_queue(netdev);
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2868
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2869
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2870
#ifdef NETIF_F_TSO
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2871
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2872
	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
  2873
	    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
  2874
		e1000_unmap_and_free_tx_resource(
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2875
		    adapter, &adapter->previous_buffer_info);
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
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2878
	return cleaned;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2879
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2880
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2881
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2882
 * 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
  2883
 * @adapter:     board private structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2884
 * @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
  2885
 * @csum:        receive descriptor csum field
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2886
 * @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
  2887
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2888
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2889
static inline void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2890
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
  2891
		  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
  2892
		  struct sk_buff *skb)
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
	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
  2895
	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
  2896
	skb->ip_summed = CHECKSUM_NONE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2897
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2898
	/* 82543 or newer only */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2899
	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
  2900
	/* Ignore Checksum bit is set */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2901
	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
  2902
	/* 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
  2903
	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
  2904
		/* let the stack verify checksum errors */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2905
		adapter->hw_csum_err++;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2906
		return;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2907
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2908
	/* 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
  2909
	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
  2910
		if(!(status & E1000_RXD_STAT_TCPCS))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2911
			return;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2912
	} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2913
		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
  2914
			return;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2915
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2916
	/* 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
  2917
	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
  2918
		/* TCP checksum is good */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2919
		skb->ip_summed = CHECKSUM_UNNECESSARY;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2920
	} 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
  2921
		/* IP fragment with UDP payload */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2922
		/* 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
  2923
		 * 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
  2924
		 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2925
		csum = ntohl(csum ^ 0xFFFF);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2926
		skb->csum = csum;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2927
		skb->ip_summed = CHECKSUM_HW;
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
	adapter->hw_csum_good++;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2930
}
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
 * 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
  2934
 * @adapter: board private structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2935
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2936
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2937
static boolean_t
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2938
#ifdef CONFIG_E1000_NAPI
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2939
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
  2940
                   int work_to_do)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2941
#else
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2942
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
  2943
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2944
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2945
	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
  2946
	struct net_device *netdev = adapter->netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2947
	struct pci_dev *pdev = adapter->pdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2948
	struct e1000_rx_desc *rx_desc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2949
	struct e1000_buffer *buffer_info;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2950
	struct sk_buff *skb;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2951
	unsigned long flags;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2952
	uint32_t length;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2953
	uint8_t last_byte;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2954
	unsigned int i;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2955
	boolean_t cleaned = FALSE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2956
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2957
	i = rx_ring->next_to_clean;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2958
	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
  2959
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2960
	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
  2961
		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
  2962
#ifdef CONFIG_E1000_NAPI
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2963
		if(*work_done >= work_to_do)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2964
			break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2965
		(*work_done)++;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2966
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2967
		cleaned = TRUE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2968
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2969
		pci_unmap_single(pdev,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2970
		                 buffer_info->dma,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2971
		                 buffer_info->length,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2972
		                 PCI_DMA_FROMDEVICE);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2973
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2974
		skb = buffer_info->skb;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2975
		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
  2976
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2977
		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
  2978
			/* 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
  2979
			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
  2980
				  " buffers\n", netdev->name);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2981
			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
  2982
			goto next_desc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2983
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2984
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2985
		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
  2986
			last_byte = *(skb->data + length - 1);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2987
			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
  2988
			              rx_desc->errors, length, last_byte)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2989
				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
  2990
				e1000_tbi_adjust_stats(&adapter->hw,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2991
				                       &adapter->stats,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2992
				                       length, skb->data);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2993
				spin_unlock_irqrestore(&adapter->stats_lock,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2994
				                       flags);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2995
				length--;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2996
			} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2997
				dev_kfree_skb_irq(skb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2998
				goto next_desc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2999
			}
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
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3002
		/* Good Receive */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3003
		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
  3004
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3005
		/* Receive Checksum Offload */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3006
		e1000_rx_checksum(adapter,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3007
				  (uint32_t)(rx_desc->status) |
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3008
				  ((uint32_t)(rx_desc->errors) << 24),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3009
				  rx_desc->csum, skb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3010
		if (adapter->ecdev) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3011
			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
  3012
			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
  3013
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3014
			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
  3015
				/* 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
  3016
				 * 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
  3017
				 * 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
  3018
				 * 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
  3019
				wmb();
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3020
				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
  3021
			}
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3022
		} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3023
			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
  3024
#ifdef CONFIG_E1000_NAPI
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3025
			if(unlikely(adapter->vlgrp &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3026
						(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
  3027
				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
  3028
						le16_to_cpu(rx_desc->special) &
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3029
						E1000_RXD_SPC_VLAN_MASK);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3030
			} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3031
				netif_receive_skb(skb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3032
			}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3033
#else /* CONFIG_E1000_NAPI */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3034
			if(unlikely(adapter->vlgrp &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3035
						(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
  3036
				vlan_hwaccel_rx(skb, adapter->vlgrp,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3037
						le16_to_cpu(rx_desc->special) &
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3038
						E1000_RXD_SPC_VLAN_MASK);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3039
			} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3040
				netif_rx(skb);
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
#endif /* CONFIG_E1000_NAPI */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3043
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3044
		netdev->last_rx = jiffies;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3045
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3046
next_desc:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3047
		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
  3048
		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
  3049
		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
  3050
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3051
		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
  3052
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3053
	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
  3054
	if (adapter->ecdev) {
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3055
		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
  3056
	} else {
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3057
		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
  3058
	}
673
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
	return cleaned;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3061
}
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
 * 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
  3065
 * @adapter: board private structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3066
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3067
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3068
static boolean_t
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3069
#ifdef CONFIG_E1000_NAPI
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3070
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
  3071
                      int work_to_do)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3072
#else
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3073
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
  3074
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3075
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3076
	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
  3077
	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
  3078
	struct net_device *netdev = adapter->netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3079
	struct pci_dev *pdev = adapter->pdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3080
	struct e1000_buffer *buffer_info;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3081
	struct e1000_ps_page *ps_page;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3082
	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
  3083
	struct sk_buff *skb;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3084
	unsigned int i, j;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3085
	uint32_t length, staterr;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3086
	boolean_t cleaned = FALSE;
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
	i = rx_ring->next_to_clean;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3089
	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
  3090
	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
  3091
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3092
	while(staterr & E1000_RXD_STAT_DD) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3093
		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
  3094
		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
  3095
		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
  3096
#ifdef CONFIG_E1000_NAPI
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3097
		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
  3098
			break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3099
		(*work_done)++;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3100
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3101
		cleaned = TRUE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3102
		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
  3103
				 buffer_info->length,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3104
				 PCI_DMA_FROMDEVICE);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3105
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3106
		skb = buffer_info->skb;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3107
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3108
		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
  3109
			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
  3110
				  " the full packet\n", netdev->name);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3111
			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
  3112
			goto next_desc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3113
		}
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
		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
  3116
			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
  3117
			goto next_desc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3118
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3119
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3120
		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
  3121
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3122
		if(unlikely(!length)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3123
			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
  3124
				  " multiple descriptors\n", netdev->name);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3125
			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
  3126
			goto next_desc;
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
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3129
		/* Good Receive */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3130
		skb_put(skb, length);
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
		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
  3133
			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
  3134
				break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3135
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3136
			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
  3137
					PAGE_SIZE, PCI_DMA_FROMDEVICE);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3138
			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
  3139
			skb_shinfo(skb)->frags[j].page =
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3140
				ps_page->ps_page[j];
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3141
			ps_page->ps_page[j] = NULL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3142
			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
  3143
			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
  3144
			skb_shinfo(skb)->nr_frags++;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3145
			skb->len += length;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3146
			skb->data_len += length;
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
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3149
		e1000_rx_checksum(adapter, staterr,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3150
				  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
  3151
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3152
#ifdef HAVE_RX_ZERO_COPY
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3153
		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
  3154
			  E1000_RXDPS_HDRSTAT_HDRSP))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3155
			skb_shinfo(skb)->zero_copy = TRUE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3156
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3157
		if (adapter->ecdev) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3158
			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
  3159
			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
  3160
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3161
			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
  3162
				/* 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
  3163
				 * 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
  3164
				 * 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
  3165
				 * 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
  3166
				wmb();
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3167
				/* 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
  3168
				 * 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
  3169
				 * twice as much.
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3170
				 */
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3171
				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
  3172
			}
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3173
		} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3174
			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
  3175
#ifdef CONFIG_E1000_NAPI
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3176
			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
  3177
				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
  3178
						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
  3179
						E1000_RXD_SPC_VLAN_MASK);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3180
			} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3181
				netif_receive_skb(skb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3182
			}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3183
#else /* CONFIG_E1000_NAPI */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3184
			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
  3185
				vlan_hwaccel_rx(skb, adapter->vlgrp,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3186
						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
  3187
						E1000_RXD_SPC_VLAN_MASK);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3188
			} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3189
				netif_rx(skb);
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
#endif /* CONFIG_E1000_NAPI */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3192
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3193
		netdev->last_rx = jiffies;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3194
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3195
next_desc:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3196
		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
  3197
		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
  3198
		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
  3199
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3200
		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
  3201
		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
  3202
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3203
	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
  3204
	if (adapter->ecdev) { 
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3205
		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
  3206
	} else {
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3207
		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
  3208
	}
673
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
	return cleaned;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3211
}
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
 * 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
  3215
 * @adapter: address of board private structure
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
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3218
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3219
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
  3220
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3221
	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
  3222
	struct net_device *netdev = adapter->netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3223
	struct pci_dev *pdev = adapter->pdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3224
	struct e1000_rx_desc *rx_desc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3225
	struct e1000_buffer *buffer_info;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3226
	struct sk_buff *skb;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3227
	unsigned int i;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3228
	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
  3229
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3230
	i = rx_ring->next_to_use;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3231
	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
  3232
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3233
	while(!buffer_info->skb) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3234
		skb = dev_alloc_skb(bufsz);
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
		if(unlikely(!skb)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3237
			/* Better luck next round */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3238
			break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3239
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3240
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3241
		/* 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
  3242
		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
  3243
			struct sk_buff *oldskb = skb;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3244
			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
  3245
					     "at %p\n", bufsz, skb->data);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3246
			/* Try again, without freeing the previous */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3247
			skb = dev_alloc_skb(bufsz);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3248
			/* Failed allocation, critical failure */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3249
			if (!skb) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3250
				dev_kfree_skb(oldskb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3251
				break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3252
			}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3253
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3254
			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
  3255
				/* give up */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3256
				dev_kfree_skb(skb);
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
				break; /* while !buffer_info->skb */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3259
			} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3260
				/* Use new allocation */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3261
				dev_kfree_skb(oldskb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3262
			}
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
		/* 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
  3265
		 * 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
  3266
		 * 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
  3267
		 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3268
		skb_reserve(skb, NET_IP_ALIGN);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3269
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3270
		skb->dev = netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3271
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3272
		buffer_info->skb = skb;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3273
		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
  3274
		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
  3275
						  skb->data,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3276
						  adapter->rx_buffer_len,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3277
						  PCI_DMA_FROMDEVICE);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3278
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3279
		/* 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
  3280
		if (!e1000_check_64k_bound(adapter,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3281
					(void *)(unsigned long)buffer_info->dma,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3282
					adapter->rx_buffer_len)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3283
			DPRINTK(RX_ERR, ERR,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3284
				"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
  3285
				adapter->rx_buffer_len,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3286
				(void *)(unsigned long)buffer_info->dma);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3287
			dev_kfree_skb(skb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3288
			buffer_info->skb = NULL;
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
			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
  3291
					 adapter->rx_buffer_len,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3292
					 PCI_DMA_FROMDEVICE);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3293
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3294
			break; /* while !buffer_info->skb */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3295
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3296
		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
  3297
		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
  3298
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3299
		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
  3300
			/* 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
  3301
			 * 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
  3302
			 * 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
  3303
			 * such as IA-64). */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3304
			wmb();
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3305
			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
  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
		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
  3309
		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
  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
	rx_ring->next_to_use = i;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3313
}
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
 * 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
  3317
 * @adapter: address of board private structure
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
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3320
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3321
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
  3322
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3323
	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
  3324
	struct net_device *netdev = adapter->netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3325
	struct pci_dev *pdev = adapter->pdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3326
	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
  3327
	struct e1000_buffer *buffer_info;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3328
	struct e1000_ps_page *ps_page;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3329
	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
  3330
	struct sk_buff *skb;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3331
	unsigned int i, j;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3332
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3333
	i = rx_ring->next_to_use;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3334
	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
  3335
	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
  3336
	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
  3337
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3338
	while(!buffer_info->skb) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3339
		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
  3340
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3341
		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
  3342
			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
  3343
				ps_page->ps_page[j] =
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3344
					alloc_page(GFP_ATOMIC);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3345
				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
  3346
					goto no_buffers;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3347
				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
  3348
					pci_map_page(pdev,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3349
						     ps_page->ps_page[j],
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3350
						     0, PAGE_SIZE,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3351
						     PCI_DMA_FROMDEVICE);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3352
			}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3353
			/* 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
  3354
			 * 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
  3355
			 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3356
			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
  3357
				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
  3358
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3359
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3360
		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
  3361
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3362
		if(unlikely(!skb))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3363
			break;
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
		/* 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
  3366
		 * 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
  3367
		 * 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
  3368
		 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3369
		skb_reserve(skb, NET_IP_ALIGN);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3370
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3371
		skb->dev = netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3372
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3373
		buffer_info->skb = skb;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3374
		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
  3375
		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
  3376
						  adapter->rx_ps_bsize0,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3377
						  PCI_DMA_FROMDEVICE);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3378
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3379
		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
  3380
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3381
		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
  3382
			/* 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
  3383
			 * 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
  3384
			 * 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
  3385
			 * such as IA-64). */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3386
			wmb();
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3387
			/* 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
  3388
			 * 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
  3389
			 * twice as much.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3390
			 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3391
			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
  3392
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3393
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3394
		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
  3395
		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
  3396
		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
  3397
		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
  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
no_buffers:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3401
	rx_ring->next_to_use = i;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3402
}
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
 * 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
  3406
 * @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
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3409
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3410
e1000_smartspeed(struct e1000_adapter *adapter)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3411
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3412
	uint16_t phy_status;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3413
	uint16_t phy_ctrl;
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->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
  3416
	   !(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
  3417
		return;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3418
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3419
	if(adapter->smartspeed == 0) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3420
		/* 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
  3421
		 * we assume back-to-back */
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_STATUS, &phy_status);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3423
		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
  3424
		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
  3425
		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
  3426
		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
  3427
		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
  3428
			phy_ctrl &= ~CR_1000T_MS_ENABLE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3429
			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
  3430
					    phy_ctrl);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3431
			adapter->smartspeed++;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3432
			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
  3433
			   !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
  3434
				   	       &phy_ctrl)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3435
				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
  3436
					     MII_CR_RESTART_AUTO_NEG);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3437
				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
  3438
						    phy_ctrl);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3439
			}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3440
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3441
		return;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3442
	} 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
  3443
		/* 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
  3444
		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
  3445
		phy_ctrl |= CR_1000T_MS_ENABLE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3446
		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
  3447
		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
  3448
		   !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
  3449
			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
  3450
				     MII_CR_RESTART_AUTO_NEG);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3451
			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
  3452
		}
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
	/* 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
  3455
	if(adapter->smartspeed++ == E1000_SMARTSPEED_MAX)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3456
		adapter->smartspeed = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3457
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3458
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3459
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3460
 * e1000_ioctl -
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3461
 * @netdev:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3462
 * @ifreq:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3463
 * @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
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3466
static int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3467
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
  3468
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3469
	switch (cmd) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3470
	case SIOCGMIIPHY:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3471
	case SIOCGMIIREG:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3472
	case SIOCSMIIREG:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3473
		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
  3474
	default:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3475
		return -EOPNOTSUPP;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3476
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3477
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3478
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3479
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3480
 * e1000_mii_ioctl -
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3481
 * @netdev:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3482
 * @ifreq:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3483
 * @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
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3486
static int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3487
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
  3488
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3489
	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
  3490
	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
  3491
	int retval;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3492
	uint16_t mii_reg;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3493
	uint16_t spddplx;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3494
	unsigned long flags;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3495
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3496
	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
  3497
		return -EOPNOTSUPP;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3498
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3499
	switch (cmd) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3500
	case SIOCGMIIPHY:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3501
		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
  3502
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3503
	case SIOCGMIIREG:
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3504
		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
  3505
			return -EPERM;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3506
		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
  3507
		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
  3508
				   &data->val_out)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3509
			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
  3510
			return -EIO;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3511
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3512
		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
  3513
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3514
	case SIOCSMIIREG:
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3515
		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
  3516
			return -EPERM;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3517
		if(data->reg_num & ~(0x1F))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3518
			return -EFAULT;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3519
		mii_reg = data->val_in;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3520
		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
  3521
		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
  3522
					mii_reg)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3523
			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
  3524
			return -EIO;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3525
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3526
		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
  3527
			switch (data->reg_num) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3528
			case PHY_CTRL:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3529
				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
  3530
					break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3531
				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
  3532
					adapter->hw.autoneg = 1;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3533
					adapter->hw.autoneg_advertised = 0x2F;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3534
				} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3535
					if (mii_reg & 0x40)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3536
						spddplx = SPEED_1000;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3537
					else if (mii_reg & 0x2000)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3538
						spddplx = SPEED_100;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3539
					else
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3540
						spddplx = SPEED_10;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3541
					spddplx += (mii_reg & 0x100)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3542
						   ? FULL_DUPLEX :
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3543
						   HALF_DUPLEX;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3544
					retval = e1000_set_spd_dplx(adapter,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3545
								    spddplx);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3546
					if(retval) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3547
						spin_unlock_irqrestore(
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3548
							&adapter->stats_lock, 
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3549
							flags);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3550
						return retval;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3551
					}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3552
				}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3553
				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
  3554
					e1000_down(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3555
					e1000_up(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3556
				} else
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3557
					e1000_reset(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3558
				break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3559
			case M88E1000_PHY_SPEC_CTRL:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3560
			case M88E1000_EXT_PHY_SPEC_CTRL:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3561
				if(e1000_phy_reset(&adapter->hw)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3562
					spin_unlock_irqrestore(
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3563
						&adapter->stats_lock, flags);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3564
					return -EIO;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3565
				}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3566
				break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3567
			}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3568
		} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3569
			switch (data->reg_num) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3570
			case PHY_CTRL:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3571
				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
  3572
					break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3573
				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
  3574
					e1000_down(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3575
					e1000_up(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3576
				} else
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3577
					e1000_reset(adapter);
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
			}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3580
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3581
		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
  3582
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3583
	default:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3584
		return -EOPNOTSUPP;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3585
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3586
	return E1000_SUCCESS;
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
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3589
void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3590
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
  3591
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3592
	struct e1000_adapter *adapter = hw->back;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3593
	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
  3594
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3595
	if(ret_val)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3596
		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
  3597
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3598
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3599
void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3600
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
  3601
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3602
	struct e1000_adapter *adapter = hw->back;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3603
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3604
	pci_clear_mwi(adapter->pdev);
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
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3607
void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3608
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
  3609
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3610
	struct e1000_adapter *adapter = hw->back;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3611
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3612
	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
  3613
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3614
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3615
void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3616
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
  3617
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3618
	struct e1000_adapter *adapter = hw->back;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3619
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3620
	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
  3621
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3622
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3623
uint32_t
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3624
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
  3625
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3626
	return inl(port);
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
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3629
void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3630
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
  3631
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3632
	outl(value, port);
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
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3635
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3636
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
  3637
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3638
	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
  3639
	uint32_t ctrl, rctl;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3640
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3641
	e1000_irq_disable(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3642
	adapter->vlgrp = grp;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3643
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3644
	if(grp) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3645
		/* enable VLAN tag insert/strip */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3646
		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
  3647
		ctrl |= E1000_CTRL_VME;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3648
		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
  3649
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3650
		/* enable VLAN receive filtering */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3651
		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
  3652
		rctl |= E1000_RCTL_VFE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3653
		rctl &= ~E1000_RCTL_CFIEN;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3654
		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
  3655
		e1000_update_mng_vlan(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3656
	} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3657
		/* disable VLAN tag insert/strip */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3658
		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
  3659
		ctrl &= ~E1000_CTRL_VME;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3660
		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
  3661
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3662
		/* disable VLAN filtering */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3663
		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
  3664
		rctl &= ~E1000_RCTL_VFE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3665
		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
  3666
		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
  3667
			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
  3668
			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
  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
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3672
	e1000_irq_enable(adapter);
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
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3675
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3676
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
  3677
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3678
	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
  3679
	uint32_t vfta, index;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3680
	if((adapter->hw.mng_cookie.status &
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3681
		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
  3682
		(vid == adapter->mng_vlan_id))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3683
		return;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3684
	/* add VID to filter table */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3685
	index = (vid >> 5) & 0x7F;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3686
	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
  3687
	vfta |= (1 << (vid & 0x1F));
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3688
	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
  3689
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3690
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3691
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3692
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
  3693
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3694
	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
  3695
	uint32_t vfta, index;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3696
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3697
	e1000_irq_disable(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3698
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3699
	if(adapter->vlgrp)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3700
		adapter->vlgrp->vlan_devices[vid] = NULL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3701
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3702
	e1000_irq_enable(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3703
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3704
	if((adapter->hw.mng_cookie.status &
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3705
		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
  3706
		(vid == adapter->mng_vlan_id))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3707
		return;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3708
	/* remove VID from filter table */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3709
	index = (vid >> 5) & 0x7F;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3710
	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
  3711
	vfta &= ~(1 << (vid & 0x1F));
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3712
	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
  3713
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3714
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3715
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3716
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
  3717
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3718
	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
  3719
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3720
	if(adapter->vlgrp) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3721
		uint16_t vid;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3722
		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
  3723
			if(!adapter->vlgrp->vlan_devices[vid])
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3724
				continue;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3725
			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
  3726
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3727
	}
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
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3730
int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3731
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
  3732
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3733
	adapter->hw.autoneg = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3734
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3735
	/* 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
  3736
	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
  3737
		spddplx != (SPEED_1000 + DUPLEX_FULL)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3738
		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
  3739
		return -EINVAL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3740
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3741
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3742
	switch(spddplx) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3743
	case SPEED_10 + DUPLEX_HALF:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3744
		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
  3745
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3746
	case SPEED_10 + DUPLEX_FULL:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3747
		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
  3748
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3749
	case SPEED_100 + DUPLEX_HALF:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3750
		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
  3751
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3752
	case SPEED_100 + DUPLEX_FULL:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3753
		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
  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_FULL:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3756
		adapter->hw.autoneg = 1;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3757
		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
  3758
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3759
	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
  3760
	default:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3761
		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
  3762
		return -EINVAL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3763
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3764
	return 0;
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
724
f188f8a0cafd Include e1000_suspend() in #ifdef CONFIG_PM.
Florian Pose <fp@igh-essen.com>
parents: 677
diff changeset
  3767
#ifdef CONFIG_PM
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3768
static int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3769
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
  3770
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3771
	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
  3772
	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
  3773
	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
  3774
	uint32_t wufc = adapter->wol;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3775
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3776
	if (!adapter->ecdev)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3777
		netif_device_detach(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3778
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3779
	if (adapter->ecdev || netif_running(netdev))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3780
		e1000_down(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3781
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3782
	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
  3783
	if(status & E1000_STATUS_LU)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3784
		wufc &= ~E1000_WUFC_LNKC;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3785
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3786
	if(wufc) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3787
		e1000_setup_rctl(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3788
		e1000_set_multi(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3789
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3790
		/* 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
  3791
		if(adapter->wol & E1000_WUFC_MC) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3792
			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
  3793
			rctl |= E1000_RCTL_MPE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3794
			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
  3795
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3796
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3797
		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
  3798
			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
  3799
			/* advertise wake from D3Cold */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3800
			#define E1000_CTRL_ADVD3WUC 0x00100000
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3801
			/* phy power management enable */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3802
			#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
  3803
			ctrl |= E1000_CTRL_ADVD3WUC |
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3804
				E1000_CTRL_EN_PHY_PWR_MGMT;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3805
			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
  3806
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3807
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3808
		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
  3809
		   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
  3810
			/* keep the laser running in D3 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3811
			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
  3812
			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
  3813
			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
  3814
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3815
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3816
		/* 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
  3817
		e1000_disable_pciex_master(&adapter->hw);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3818
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, E1000_WUC_PME_EN);
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, wufc);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3821
		pci_enable_wake(pdev, 3, 1);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3822
		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
  3823
	} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3824
		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
  3825
		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
  3826
		pci_enable_wake(pdev, 3, 0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3827
		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
  3828
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3829
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3830
	pci_save_state(pdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3831
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3832
	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
  3833
	   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
  3834
		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
  3835
		if(manc & E1000_MANC_SMBUS_EN) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3836
			manc |= E1000_MANC_ARP_EN;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3837
			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
  3838
			pci_enable_wake(pdev, 3, 1);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3839
			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
  3840
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3841
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3842
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3843
	switch(adapter->hw.mac_type) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3844
	case e1000_82573:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3845
		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
  3846
		E1000_WRITE_REG(&adapter->hw, SWSM,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3847
				swsm & ~E1000_SWSM_DRV_LOAD);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3848
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3849
	default:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3850
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3851
	}
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
	pci_disable_device(pdev);
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
	state = (state > 0) ? 3 : 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3856
	pci_set_power_state(pdev, state);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3857
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3858
	return 0;
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
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3861
static int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3862
e1000_resume(struct pci_dev *pdev)
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
	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
  3865
	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
  3866
	uint32_t manc, ret_val, swsm;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3867
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3868
	pci_set_power_state(pdev, 0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3869
	pci_restore_state(pdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3870
	ret_val = pci_enable_device(pdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3871
	pci_set_master(pdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3872
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3873
	pci_enable_wake(pdev, 3, 0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3874
	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
  3875
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3876
	e1000_reset(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3877
	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
  3878
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3879
	if(adapter->ecdev || netif_running(netdev))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3880
		e1000_up(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3881
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3882
	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
  3883
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3884
	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
  3885
	   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
  3886
		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
  3887
		manc &= ~(E1000_MANC_ARP_EN);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3888
		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
  3889
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3890
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3891
	switch(adapter->hw.mac_type) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3892
	case e1000_82573:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3893
		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
  3894
		E1000_WRITE_REG(&adapter->hw, SWSM,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3895
				swsm | E1000_SWSM_DRV_LOAD);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3896
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3897
	default:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3898
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3899
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3900
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3901
	return 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3902
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3903
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3904
#ifdef CONFIG_NET_POLL_CONTROLLER
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
 * 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
  3907
 * 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
  3908
 * the interrupt routine is executing.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3909
 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3910
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3911
e1000_netpoll(struct net_device *netdev)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3912
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3913
	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
  3914
	disable_irq(adapter->pdev->irq);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3915
	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
  3916
	e1000_clean_tx_irq(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3917
	enable_irq(adapter->pdev->irq);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3918
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3919
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3920
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3921
/* e1000_main.c */