devices/e1000/e1000_main-2.6.13-ethercat.c
author Florian Pose <fp@igh-essen.com>
Thu, 06 Nov 2014 08:53:11 +0100
changeset 2593 e2388daebfbc
parent 2589 2b9c78543663
permissions -rw-r--r--
Cleaned up EoE frame type definitions.
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
1325
16aacb421bd4 merge -c1602 branches/stable-1.4: Fixed e1000 ring bug.
Florian Pose <fp@igh-essen.com>
parents: 1152
diff changeset
    27
  vim: noexpandtab
16aacb421bd4 merge -c1602 branches/stable-1.4: Fixed e1000 ring bug.
Florian Pose <fp@igh-essen.com>
parents: 1152
diff changeset
    28
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
*******************************************************************************/
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
#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
    32
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
/* Change Log
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
 * 6.0.58       4/20/05
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
 *   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
    36
 * 6.0.44+	2/15/05
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
 *   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
    38
 *   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
    39
 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
char e1000_driver_name[] = "ec_e1000";
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
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
    43
#ifndef CONFIG_E1000_NAPI
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
#define DRIVERNAPI
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
#else
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
#define DRIVERNAPI "-NAPI"
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    48
#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
    49
char e1000_driver_version[] = DRV_VERSION;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    50
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
    51
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    52
/* 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
    53
 *
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    54
 * Last entry must be all 0s
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    55
 *
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    56
 * Macro expands to...
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    57
 *   {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
    58
 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    59
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
    60
	INTEL_E1000_ETHERNET_DEVICE(0x1000),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    61
	INTEL_E1000_ETHERNET_DEVICE(0x1001),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    62
	INTEL_E1000_ETHERNET_DEVICE(0x1004),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    63
	INTEL_E1000_ETHERNET_DEVICE(0x1008),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    64
	INTEL_E1000_ETHERNET_DEVICE(0x1009),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    65
	INTEL_E1000_ETHERNET_DEVICE(0x100C),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    66
	INTEL_E1000_ETHERNET_DEVICE(0x100D),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    67
	INTEL_E1000_ETHERNET_DEVICE(0x100E),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    68
	INTEL_E1000_ETHERNET_DEVICE(0x100F),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    69
	INTEL_E1000_ETHERNET_DEVICE(0x1010),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    70
	INTEL_E1000_ETHERNET_DEVICE(0x1011),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    71
	INTEL_E1000_ETHERNET_DEVICE(0x1012),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    72
	INTEL_E1000_ETHERNET_DEVICE(0x1013),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    73
	INTEL_E1000_ETHERNET_DEVICE(0x1014),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    74
	INTEL_E1000_ETHERNET_DEVICE(0x1015),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    75
	INTEL_E1000_ETHERNET_DEVICE(0x1016),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    76
	INTEL_E1000_ETHERNET_DEVICE(0x1017),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    77
	INTEL_E1000_ETHERNET_DEVICE(0x1018),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    78
	INTEL_E1000_ETHERNET_DEVICE(0x1019),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    79
	INTEL_E1000_ETHERNET_DEVICE(0x101A),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    80
	INTEL_E1000_ETHERNET_DEVICE(0x101D),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    81
	INTEL_E1000_ETHERNET_DEVICE(0x101E),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    82
	INTEL_E1000_ETHERNET_DEVICE(0x1026),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    83
	INTEL_E1000_ETHERNET_DEVICE(0x1027),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    84
	INTEL_E1000_ETHERNET_DEVICE(0x1028),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    85
	INTEL_E1000_ETHERNET_DEVICE(0x1075),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    86
	INTEL_E1000_ETHERNET_DEVICE(0x1076),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    87
	INTEL_E1000_ETHERNET_DEVICE(0x1077),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    88
	INTEL_E1000_ETHERNET_DEVICE(0x1078),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    89
	INTEL_E1000_ETHERNET_DEVICE(0x1079),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    90
	INTEL_E1000_ETHERNET_DEVICE(0x107A),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    91
	INTEL_E1000_ETHERNET_DEVICE(0x107B),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    92
	INTEL_E1000_ETHERNET_DEVICE(0x107C),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    93
	INTEL_E1000_ETHERNET_DEVICE(0x108A),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    94
	INTEL_E1000_ETHERNET_DEVICE(0x108B),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    95
	INTEL_E1000_ETHERNET_DEVICE(0x108C),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    96
	INTEL_E1000_ETHERNET_DEVICE(0x1099),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    97
	/* required last entry */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    98
	{0,}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    99
};
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   100
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   101
// do not auto-load driver
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   102
// 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
   103
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   104
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
   105
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
   106
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
   107
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
   108
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
   109
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
   110
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
   111
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
   112
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
   113
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   114
/* Local Function Prototypes */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   115
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   116
static int e1000_init_module(void);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   117
static void e1000_exit_module(void);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   118
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
   119
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
   120
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
   121
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
   122
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
   123
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
   124
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
   125
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
   126
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
   127
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
   128
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
   129
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
   130
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
   131
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
   132
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
   133
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
   134
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
   135
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
   136
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
   137
void ec_poll(struct net_device *);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   138
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
   139
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
   140
#ifdef CONFIG_E1000_NAPI
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   141
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
   142
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
   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
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
   145
                                       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
   146
#else
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   147
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
   148
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
   149
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   150
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
   151
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
   152
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
   153
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
   154
			   int cmd);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   155
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
   156
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
   157
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
   158
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
   159
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
   160
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
   161
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
   162
					      struct sk_buff *skb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   163
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   164
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
   165
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
   166
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
   167
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
   168
724
f188f8a0cafd Include e1000_suspend() in #ifdef CONFIG_PM.
Florian Pose <fp@igh-essen.com>
parents: 677
diff changeset
   169
#ifdef CONFIG_PM
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   170
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
   171
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
   172
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   173
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   174
#ifdef CONFIG_NET_POLL_CONTROLLER
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   175
/* for netdump / net console */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   176
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
   177
#endif
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
/* Exported from other modules */
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
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
   182
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   183
static struct pci_driver e1000_driver = {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   184
	.name     = e1000_driver_name,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   185
	.id_table = e1000_pci_tbl,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   186
	.probe    = e1000_probe,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   187
	.remove   = __devexit_p(e1000_remove),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   188
	/* Power Managment Hooks */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   189
#ifdef CONFIG_PM
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   190
	.suspend  = e1000_suspend,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   191
	.resume   = e1000_resume
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   192
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   193
};
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   194
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   195
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
   196
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
   197
MODULE_LICENSE("GPL");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   198
MODULE_VERSION(DRV_VERSION);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   199
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   200
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
   201
module_param(debug, int, 0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   202
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
   203
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 - Driver Registration Routine
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   206
 *
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   207
 * 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
   208
 * 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
   209
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   210
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   211
static int __init
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   212
e1000_init_module(void)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   213
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   214
	int ret;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   215
	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
   216
	       e1000_driver_string, e1000_driver_version);
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
	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
   219
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   220
	ret = pci_module_init(&e1000_driver);
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
	return ret;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   223
}
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
module_init(e1000_init_module);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   226
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 - Driver Exit Cleanup Routine
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   229
 *
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   230
 * 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
   231
 * from memory.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   232
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   233
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   234
static void __exit
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   235
e1000_exit_module(void)
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
	pci_unregister_driver(&e1000_driver);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   238
}
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
module_exit(e1000_exit_module);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   241
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   242
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   243
 * 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
   244
 * @adapter: board private structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   245
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   246
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   247
static inline void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   248
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
   249
{
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
   250
    if (adapter->ecdev)
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
   251
        return;
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   252
	atomic_inc(&adapter->irq_sem);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   253
	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
   254
	E1000_WRITE_FLUSH(&adapter->hw);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   255
	synchronize_irq(adapter->pdev->irq);
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
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   258
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   259
 * 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
   260
 * @adapter: board private structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   261
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   262
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   263
static inline void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   264
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
   265
{
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
   266
    if (adapter->ecdev)
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
   267
        return;
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
   268
	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
   269
		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
   270
		E1000_WRITE_FLUSH(&adapter->hw);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   271
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   272
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   273
void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   274
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
   275
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   276
	struct net_device *netdev = adapter->netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   277
	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
   278
	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
   279
	if(adapter->vlgrp) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   280
		if(!adapter->vlgrp->vlan_devices[vid]) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   281
			if(adapter->hw.mng_cookie.status &
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   282
				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
   283
				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
   284
				adapter->mng_vlan_id = vid;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   285
			} else
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   286
				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
   287
				
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   288
			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
   289
					(vid != old_vid) && 
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   290
					!adapter->vlgrp->vlan_devices[old_vid])
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   291
				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
   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
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   295
	
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   296
int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   297
e1000_up(struct e1000_adapter *adapter)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   298
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   299
	struct net_device *netdev = adapter->netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   300
	int err;
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
	/* 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
   303
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   304
	/* 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
   305
	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
   306
		uint16_t mii_reg;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   307
		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
   308
		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
   309
			e1000_phy_reset(&adapter->hw);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   310
	}
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_set_multi(netdev);
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_restore_vlan(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   315
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   316
	e1000_configure_tx(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   317
	e1000_setup_rctl(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   318
	e1000_configure_rx(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   319
	adapter->alloc_rx_buf(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   320
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   321
#ifdef CONFIG_PCI_MSI
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   322
	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
   323
		adapter->have_msi = TRUE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   324
		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
   325
			DPRINTK(PROBE, ERR,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   326
			 "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
   327
			adapter->have_msi = FALSE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   328
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   329
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   330
#endif
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
   331
    if (!adapter->ecdev) {
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
   332
        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
   333
                        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
   334
                        netdev->name, netdev))) {
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
   335
            DPRINTK(PROBE, ERR,
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
   336
                    "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
   337
            return err;
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
   338
        }
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
   339
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
   340
        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
   341
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   342
#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
   343
        netif_poll_enable(netdev);
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   344
#endif
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
   345
        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
   346
    }
673
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
	return 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   349
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   350
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   351
void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   352
e1000_down(struct e1000_adapter *adapter)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   353
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   354
	struct net_device *netdev = adapter->netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   355
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
   356
    if (!adapter->ecdev) {
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
   357
        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
   358
        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
   359
    }
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   360
#ifdef CONFIG_PCI_MSI
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   361
	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
   362
	   adapter->have_msi == TRUE)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   363
		pci_disable_msi(adapter->pdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   364
#endif
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
   365
    if (!adapter->ecdev) {
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->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
   367
        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
   368
        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
   369
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   370
#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
   371
        netif_poll_disable(netdev);
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   372
#endif
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
   373
    }
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   374
	adapter->link_speed = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   375
	adapter->link_duplex = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   376
	if (!adapter->ecdev) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   377
		netif_carrier_off(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   378
		netif_stop_queue(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   379
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   380
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   381
	e1000_reset(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   382
	e1000_clean_tx_ring(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   383
	e1000_clean_rx_ring(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   384
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   385
	/* If WoL is not enabled
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   386
	 * and management mode is not IAMT
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   387
	 * 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
   388
	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
   389
	   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
   390
	   !e1000_check_mng_mode(&adapter->hw) &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   391
	   !(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
   392
		uint16_t mii_reg;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   393
		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
   394
		mii_reg |= MII_CR_POWER_DOWN;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   395
		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
   396
		mdelay(1);
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
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   399
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   400
void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   401
e1000_reset(struct e1000_adapter *adapter)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   402
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   403
	struct net_device *netdev = adapter->netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   404
	uint32_t pba, manc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   405
	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
   406
	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
   407
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   408
	/* 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
   409
	 * 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
   410
	 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   411
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   412
	switch (adapter->hw.mac_type) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   413
	case e1000_82547:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   414
	case e1000_82547_rev_2:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   415
		pba = E1000_PBA_30K;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   416
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   417
	case e1000_82573:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   418
		pba = E1000_PBA_12K;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   419
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   420
	default:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   421
		pba = E1000_PBA_48K;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   422
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   423
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   424
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   425
	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
   426
	   (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
   427
		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
   428
		/* 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
   429
		 * 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
   430
		*/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   431
		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
   432
					ETHERNET_FCS_SIZE + 1;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   433
		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
   434
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   435
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   436
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   437
	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
   438
		adapter->tx_fifo_head = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   439
		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
   440
		adapter->tx_fifo_size =
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   441
			(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
   442
		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
   443
	}
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
	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
   446
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   447
	/* flow control settings */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   448
	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
   449
				    fc_high_water_mark;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   450
	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
   451
				   fc_low_water_mark;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   452
	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
   453
	adapter->hw.fc_send_xon = 1;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   454
	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
   455
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   456
	/* 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
   457
	e1000_reset_hw(&adapter->hw);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   458
	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
   459
		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
   460
	if(e1000_init_hw(&adapter->hw))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   461
		DPRINTK(PROBE, ERR, "Hardware Error\n");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   462
	e1000_update_mng_vlan(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   463
	/* 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
   464
	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
   465
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   466
	e1000_reset_adaptive(&adapter->hw);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   467
	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
   468
	if (adapter->en_mng_pt) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   469
		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
   470
		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
   471
		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
   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
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   475
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   476
 * e1000_probe - Device Initialization Routine
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   477
 * @pdev: PCI device information struct
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   478
 * @ent: entry in e1000_pci_tbl
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
 * 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
   481
 *
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   482
 * 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
   483
 * 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
   484
 * and a hardware reset occur.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   485
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   486
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   487
static int __devinit
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   488
e1000_probe(struct pci_dev *pdev,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   489
            const struct pci_device_id *ent)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   490
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   491
	struct net_device *netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   492
	struct e1000_adapter *adapter;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   493
	unsigned long mmio_start, mmio_len;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   494
	uint32_t swsm;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   495
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   496
	static int cards_found = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   497
	int i, err, pci_using_dac;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   498
	uint16_t eeprom_data;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   499
	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
   500
	if((err = pci_enable_device(pdev)))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   501
		return err;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   502
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   503
	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
   504
		pci_using_dac = 1;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   505
	} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   506
		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
   507
			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
   508
			return err;
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
		pci_using_dac = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   511
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   512
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   513
	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
   514
		return err;
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
	pci_set_master(pdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   517
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   518
	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
   519
	if(!netdev) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   520
		err = -ENOMEM;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   521
		goto err_alloc_etherdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   522
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   523
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   524
	SET_MODULE_OWNER(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   525
	SET_NETDEV_DEV(netdev, &pdev->dev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   526
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   527
	pci_set_drvdata(pdev, netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   528
	adapter = netdev_priv(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   529
	adapter->netdev = netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   530
	adapter->pdev = pdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   531
	adapter->hw.back = adapter;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   532
	adapter->msg_enable = (1 << debug) - 1;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   533
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   534
	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
   535
	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
   536
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   537
	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
   538
	if(!adapter->hw.hw_addr) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   539
		err = -EIO;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   540
		goto err_ioremap;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   541
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   542
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   543
	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
   544
		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
   545
			continue;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   546
		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
   547
			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
   548
			break;
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
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   551
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   552
	netdev->open = &e1000_open;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   553
	netdev->stop = &e1000_close;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   554
	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
   555
	netdev->get_stats = &e1000_get_stats;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   556
	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
   557
	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
   558
	netdev->change_mtu = &e1000_change_mtu;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   559
	netdev->do_ioctl = &e1000_ioctl;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   560
	e1000_set_ethtool_ops(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   561
	netdev->tx_timeout = &e1000_tx_timeout;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   562
	netdev->watchdog_timeo = 5 * HZ;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   563
#ifdef CONFIG_E1000_NAPI
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   564
	netdev->poll = &e1000_clean;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   565
	netdev->weight = 64;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   566
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   567
	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
   568
	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
   569
	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
   570
#ifdef CONFIG_NET_POLL_CONTROLLER
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   571
	netdev->poll_controller = e1000_netpoll;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   572
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   573
	strcpy(netdev->name, pci_name(pdev));
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   574
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   575
	netdev->mem_start = mmio_start;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   576
	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
   577
	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
   578
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   579
	adapter->bd_number = cards_found;
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
	/* setup the private structure */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   582
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   583
	if((err = e1000_sw_init(adapter)))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   584
		goto err_sw_init;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   585
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   586
	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
   587
		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
   588
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   589
	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
   590
		netdev->features = NETIF_F_SG |
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   591
				   NETIF_F_HW_CSUM |
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   592
				   NETIF_F_HW_VLAN_TX |
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   593
				   NETIF_F_HW_VLAN_RX |
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   594
				   NETIF_F_HW_VLAN_FILTER;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   595
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   596
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   597
#ifdef NETIF_F_TSO
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   598
	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
   599
	   (adapter->hw.mac_type != e1000_82547))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   600
		netdev->features |= NETIF_F_TSO;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   601
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   602
#ifdef NETIF_F_TSO_IPV6
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   603
	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
   604
		netdev->features |= NETIF_F_TSO_IPV6;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   605
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   606
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   607
	if(pci_using_dac)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   608
		netdev->features |= NETIF_F_HIGHDMA;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   609
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   610
 	/* 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
   611
 	netdev->features |= NETIF_F_LLTX; 
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
	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
   614
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   615
	/* 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
   616
	 * 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
   617
	
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   618
	e1000_reset_hw(&adapter->hw);
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
	/* make sure the EEPROM is good */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   621
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   622
	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
   623
		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
   624
		err = -EIO;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   625
		goto err_eeprom;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   626
	}
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
	/* 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
   629
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   630
	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
   631
		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
   632
	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
   633
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   634
	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
   635
		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
   636
		err = -EIO;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   637
		goto err_eeprom;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   638
	}
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_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
   641
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   642
	e1000_get_bus_info(&adapter->hw);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   643
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   644
	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
   645
	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
   646
	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
   647
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   648
	init_timer(&adapter->watchdog_timer);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   649
	adapter->watchdog_timer.function = &e1000_watchdog;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   650
	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
   651
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   652
	INIT_WORK(&adapter->watchdog_task,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   653
		(void (*)(void *))e1000_watchdog_task, adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   654
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   655
	init_timer(&adapter->phy_info_timer);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   656
	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
   657
	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
   658
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   659
	INIT_WORK(&adapter->tx_timeout_task,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   660
		(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
   661
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   662
	/* 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
   663
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   664
	if (!adapter->ecdev) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   665
		netif_carrier_off(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   666
		netif_stop_queue(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   667
	}
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
	e1000_check_options(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   670
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   671
	/* Initial Wake on LAN setting
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   672
	 * 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
   673
	 * enable the ACPI Magic Packet filter
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   674
	 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   675
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   676
	switch(adapter->hw.mac_type) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   677
	case e1000_82542_rev2_0:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   678
	case e1000_82542_rev2_1:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   679
	case e1000_82543:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   680
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   681
	case e1000_82544:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   682
		e1000_read_eeprom(&adapter->hw,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   683
			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
   684
		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
   685
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   686
	case e1000_82546:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   687
	case e1000_82546_rev_3:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   688
		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
   689
		   && (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
   690
			e1000_read_eeprom(&adapter->hw,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   691
				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
   692
			break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   693
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   694
		/* Fall Through */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   695
	default:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   696
		e1000_read_eeprom(&adapter->hw,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   697
			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
   698
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   699
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   700
	if(eeprom_data & eeprom_apme_mask)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   701
		adapter->wol |= E1000_WUFC_MAG;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   702
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   703
	/* 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
   704
	e1000_reset(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   705
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   706
	/* 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
   707
	switch(adapter->hw.mac_type) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   708
	case e1000_82573:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   709
		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
   710
		E1000_WRITE_REG(&adapter->hw, SWSM,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   711
				swsm | E1000_SWSM_DRV_LOAD);
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
	default:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   714
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   715
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   716
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   717
	// offer device to EtherCAT master module
1011
a0759d0dded4 Improved ecdev_offer().
Florian Pose <fp@igh-essen.com>
parents: 727
diff changeset
   718
	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
   719
	if (adapter->ecdev) {
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2050
diff changeset
   720
		err = ecdev_open(adapter->ecdev);
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2050
diff changeset
   721
		if (err) {
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   722
			ecdev_withdraw(adapter->ecdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   723
			goto err_register;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   724
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   725
	} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   726
		strcpy(netdev->name, "eth%d");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   727
		if ((err = register_netdev(netdev)))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   728
			goto err_register;
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
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   731
	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
   732
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   733
	cards_found++;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   734
	return 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   735
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   736
err_register:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   737
err_sw_init:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   738
err_eeprom:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   739
	iounmap(adapter->hw.hw_addr);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   740
err_ioremap:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   741
	free_netdev(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   742
err_alloc_etherdev:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   743
	pci_release_regions(pdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   744
	return err;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   745
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   746
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   747
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   748
 * e1000_remove - Device Removal Routine
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   749
 * @pdev: PCI device information struct
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   750
 *
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   751
 * 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
   752
 * 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
   753
 * 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
   754
 * memory.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   755
 **/
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
static void __devexit
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   758
e1000_remove(struct pci_dev *pdev)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   759
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   760
	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
   761
	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
   762
	uint32_t manc, swsm;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   763
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   764
	flush_scheduled_work();
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   765
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   766
	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
   767
	   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
   768
		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
   769
		if(manc & E1000_MANC_SMBUS_EN) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   770
			manc |= E1000_MANC_ARP_EN;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   771
			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
   772
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   773
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   774
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   775
	switch(adapter->hw.mac_type) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   776
	case e1000_82573:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   777
		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
   778
		E1000_WRITE_REG(&adapter->hw, SWSM,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   779
				swsm & ~E1000_SWSM_DRV_LOAD);
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
	default:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   783
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   784
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   785
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   786
	if (adapter->ecdev) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   787
		ecdev_close(adapter->ecdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   788
		ecdev_withdraw(adapter->ecdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   789
	} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   790
		unregister_netdev(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   791
	}
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
	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
   794
		e1000_phy_hw_reset(&adapter->hw);
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
	iounmap(adapter->hw.hw_addr);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   797
	pci_release_regions(pdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   798
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   799
	free_netdev(netdev);
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
	pci_disable_device(pdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   802
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   803
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   804
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   805
 * 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
   806
 * @adapter: board private structure to initialize
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   807
 *
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   808
 * 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
   809
 * 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
   810
 * OS network device settings (MTU size).
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   811
 **/
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
static int __devinit
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   814
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
   815
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   816
	struct e1000_hw *hw = &adapter->hw;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   817
	struct net_device *netdev = adapter->netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   818
	struct pci_dev *pdev = adapter->pdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   819
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   820
	/* PCI config space info */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   821
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   822
	hw->vendor_id = pdev->vendor;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   823
	hw->device_id = pdev->device;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   824
	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
   825
	hw->subsystem_id = pdev->subsystem_device;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   826
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   827
	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
   828
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   829
	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
   830
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   831
	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
   832
	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
   833
	hw->max_frame_size = netdev->mtu +
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   834
			     ENET_HEADER_SIZE + ETHERNET_FCS_SIZE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   835
	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
   836
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   837
	/* identify the MAC */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   838
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   839
	if(e1000_set_mac_type(hw)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   840
		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
   841
		return -EIO;
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
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   844
	/* initialize eeprom parameters */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   845
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   846
	if(e1000_init_eeprom_params(hw)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   847
		E1000_ERR("EEPROM initialization failed\n");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   848
		return -EIO;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   849
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   850
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   851
	switch(hw->mac_type) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   852
	default:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   853
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   854
	case e1000_82541:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   855
	case e1000_82547:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   856
	case e1000_82541_rev_2:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   857
	case e1000_82547_rev_2:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   858
		hw->phy_init_script = 1;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   859
		break;
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
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   862
	e1000_set_media_type(hw);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   863
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   864
	hw->wait_autoneg_complete = FALSE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   865
	hw->tbi_compatibility_en = TRUE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   866
	hw->adaptive_ifs = TRUE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   867
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   868
	/* Copper options */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   869
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   870
	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
   871
		hw->mdix = AUTO_ALL_MODES;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   872
		hw->disable_polarity_correction = FALSE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   873
		hw->master_slave = E1000_MASTER_SLAVE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   874
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   875
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   876
	atomic_set(&adapter->irq_sem, 1);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   877
	spin_lock_init(&adapter->stats_lock);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   878
	spin_lock_init(&adapter->tx_lock);
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
	return 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   881
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   882
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   883
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   884
 * 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
   885
 * @netdev: network interface device structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   886
 *
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   887
 * 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
   888
 *
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   889
 * 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
   890
 * 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
   891
 * 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
   892
 * 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
   893
 * 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
   894
 **/
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
static int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   897
e1000_open(struct net_device *netdev)
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
	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
   900
	int err;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   901
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   902
	/* allocate transmit descriptors */
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
	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
   905
		goto err_setup_tx;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   906
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   907
	/* allocate receive descriptors */
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_setup_rx_resources(adapter)))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   910
		goto err_setup_rx;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   911
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   912
	if((err = e1000_up(adapter)))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   913
		goto err_up;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   914
	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
   915
	if((adapter->hw.mng_cookie.status &
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   916
			  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
   917
		e1000_update_mng_vlan(adapter);
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
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   920
	return E1000_SUCCESS;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   921
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   922
err_up:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   923
	e1000_free_rx_resources(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   924
err_setup_rx:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   925
	e1000_free_tx_resources(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   926
err_setup_tx:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   927
	e1000_reset(adapter);
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
	return err;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   930
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   931
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   932
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   933
 * e1000_close - Disables a network interface
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   934
 * @netdev: network interface device structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   935
 *
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   936
 * 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
   937
 *
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   938
 * 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
   939
 * 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
   940
 * 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
   941
 * 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
   942
 **/
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
static int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   945
e1000_close(struct net_device *netdev)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   946
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   947
	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
   948
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   949
	e1000_down(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
	e1000_free_tx_resources(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   952
	e1000_free_rx_resources(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   953
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   954
	if((adapter->hw.mng_cookie.status &
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   955
			  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
   956
		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
   957
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   958
	return 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   959
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   960
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   961
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   962
 * 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
   963
 * @adapter: address of board private structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   964
 * @start: address of beginning of memory
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   965
 * @len: length of memory
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   966
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   967
static inline boolean_t
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   968
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
   969
		      void *start, unsigned long 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
	unsigned long begin = (unsigned long) start;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   972
	unsigned long end = begin + len;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   973
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   974
	/* 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
   975
	 * 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
   976
	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
   977
	    adapter->hw.mac_type == e1000_82546) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   978
		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
   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
	return TRUE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   982
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   983
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   984
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   985
 * 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
   986
 * @adapter: board private structure
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
 * 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
   989
 **/
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
int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   992
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
   993
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   994
	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
   995
	struct pci_dev *pdev = adapter->pdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   996
	int size;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   997
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   998
	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
   999
	txdr->buffer_info = vmalloc(size);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1000
	if(!txdr->buffer_info) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1001
		DPRINTK(PROBE, ERR,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1002
		"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
  1003
		return -ENOMEM;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1004
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1005
	memset(txdr->buffer_info, 0, size);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1006
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1007
	/* round up to nearest 4K */
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->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
  1010
	E1000_ROUNDUP(txdr->size, 4096);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1011
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1012
	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
  1013
	if(!txdr->desc) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1014
setup_tx_desc_die:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1015
		vfree(txdr->buffer_info);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1016
		DPRINTK(PROBE, ERR,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1017
		"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
  1018
		return -ENOMEM;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1019
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1020
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1021
	/* 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
  1022
	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
  1023
		void *olddesc = txdr->desc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1024
		dma_addr_t olddma = txdr->dma;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1025
		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
  1026
				     "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
  1027
		/* Try again, without freeing the previous */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1028
		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
  1029
		if(!txdr->desc) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1030
		/* Failed allocation, critical failure */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1031
			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
  1032
			goto setup_tx_desc_die;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1033
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1034
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1035
		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
  1036
			/* give up */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1037
			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
  1038
					    txdr->dma);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1039
			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
  1040
			DPRINTK(PROBE, ERR,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1041
				"Unable to allocate aligned memory "
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1042
				"for the transmit descriptor ring\n");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1043
			vfree(txdr->buffer_info);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1044
			return -ENOMEM;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1045
		} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1046
			/* 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
  1047
			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
  1048
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1049
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1050
	memset(txdr->desc, 0, txdr->size);
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
	txdr->next_to_use = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1053
	txdr->next_to_clean = 0;
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
	return 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1056
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1057
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1058
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1059
 * 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
  1060
 * @adapter: board private structure
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
 * 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
  1063
 **/
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
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1066
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
  1067
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1068
	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
  1069
	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
  1070
	uint32_t tctl, tipg;
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, TDBAL, (tdba & 0x00000000ffffffffULL));
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1073
	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
  1074
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1075
	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
  1076
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1077
	/* 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
  1078
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1079
	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
  1080
	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
  1081
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1082
	/* 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
  1083
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1084
	switch (adapter->hw.mac_type) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1085
	case e1000_82542_rev2_0:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1086
	case e1000_82542_rev2_1:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1087
		tipg = DEFAULT_82542_TIPG_IPGT;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1088
		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
  1089
		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
  1090
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1091
	default:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1092
		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
  1093
		   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
  1094
			tipg = DEFAULT_82543_TIPG_IPGT_FIBER;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1095
		else
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1096
			tipg = DEFAULT_82543_TIPG_IPGT_COPPER;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1097
		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
  1098
		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
  1099
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1100
	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
  1101
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1102
	/* Set the Tx Interrupt Delay register */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1103
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1104
	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
  1105
	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
  1106
		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
  1107
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1108
	/* Program the Transmit Control Register */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1109
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1110
	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
  1111
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1112
	tctl &= ~E1000_TCTL_CT;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1113
	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
  1114
		(E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1115
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1116
	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
  1117
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1118
	e1000_config_collision_dist(&adapter->hw);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1119
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1120
	/* 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
  1121
	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
  1122
		E1000_TXD_CMD_IFCS;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1123
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1124
	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
  1125
		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
  1126
	else
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1127
		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
  1128
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1129
	/* 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
  1130
	 * 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
  1131
	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
  1132
	   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
  1133
		adapter->pcix_82544 = 1;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1134
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1135
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1136
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1137
 * 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
  1138
 * @adapter: board private structure
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
 * 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
  1141
 **/
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
int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1144
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
  1145
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1146
	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
  1147
	struct pci_dev *pdev = adapter->pdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1148
	int size, desc_len;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1149
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1150
	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
  1151
	rxdr->buffer_info = vmalloc(size);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1152
	if(!rxdr->buffer_info) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1153
		DPRINTK(PROBE, ERR,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1154
		"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
  1155
		return -ENOMEM;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1156
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1157
	memset(rxdr->buffer_info, 0, size);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1158
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1159
	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
  1160
	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
  1161
	if(!rxdr->ps_page) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1162
		vfree(rxdr->buffer_info);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1163
		DPRINTK(PROBE, ERR,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1164
		"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
  1165
		return -ENOMEM;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1166
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1167
	memset(rxdr->ps_page, 0, size);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1168
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1169
	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
  1170
	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
  1171
	if(!rxdr->ps_page_dma) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1172
		vfree(rxdr->buffer_info);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1173
		kfree(rxdr->ps_page);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1174
		DPRINTK(PROBE, ERR,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1175
		"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
  1176
		return -ENOMEM;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1177
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1178
	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
  1179
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1180
	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
  1181
		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
  1182
	else
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1183
		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
  1184
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1185
	/* Round up to nearest 4K */
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->size = rxdr->count * desc_len;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1188
	E1000_ROUNDUP(rxdr->size, 4096);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1189
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1190
	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
  1191
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1192
	if(!rxdr->desc) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1193
setup_rx_desc_die:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1194
		vfree(rxdr->buffer_info);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1195
		kfree(rxdr->ps_page);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1196
		kfree(rxdr->ps_page_dma);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1197
		DPRINTK(PROBE, ERR,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1198
		"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
  1199
		return -ENOMEM;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1200
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1201
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1202
	/* 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
  1203
	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
  1204
		void *olddesc = rxdr->desc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1205
		dma_addr_t olddma = rxdr->dma;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1206
		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
  1207
				     "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
  1208
		/* Try again, without freeing the previous */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1209
		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
  1210
		if(!rxdr->desc) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1211
		/* Failed allocation, critical failure */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1212
			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
  1213
			goto setup_rx_desc_die;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1214
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1215
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1216
		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
  1217
			/* give up */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1218
			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
  1219
					    rxdr->dma);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1220
			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
  1221
			DPRINTK(PROBE, ERR,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1222
				"Unable to allocate aligned memory "
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1223
				"for the receive descriptor ring\n");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1224
			vfree(rxdr->buffer_info);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1225
			kfree(rxdr->ps_page);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1226
			kfree(rxdr->ps_page_dma);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1227
			return -ENOMEM;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1228
		} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1229
			/* 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
  1230
			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
  1231
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1232
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1233
	memset(rxdr->desc, 0, rxdr->size);
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
	rxdr->next_to_clean = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1236
	rxdr->next_to_use = 0;
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
	return 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1239
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1240
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1241
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1242
 * 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
  1243
 * @adapter: Board private structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1244
 **/
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
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1247
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
  1248
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1249
	uint32_t rctl, rfctl;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1250
	uint32_t psrctl = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1251
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1252
	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
  1253
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1254
	rctl &= ~(3 << E1000_RCTL_MO_SHIFT);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1255
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1256
	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
  1257
		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
  1258
		(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
  1259
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1260
	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
  1261
		rctl |= E1000_RCTL_SBP;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1262
	else
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1263
		rctl &= ~E1000_RCTL_SBP;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1264
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1265
	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
  1266
		rctl &= ~E1000_RCTL_LPE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1267
	else
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1268
		rctl |= E1000_RCTL_LPE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1269
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1270
	/* Setup buffer sizes */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1271
	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
  1272
		/* 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
  1273
		 * 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
  1274
		rctl |= adapter->rx_buffer_len << 0x11;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1275
	} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1276
		rctl &= ~E1000_RCTL_SZ_4096;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1277
		rctl |= E1000_RCTL_BSEX; 
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1278
		switch (adapter->rx_buffer_len) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1279
		case E1000_RXBUFFER_2048:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1280
		default:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1281
			rctl |= E1000_RCTL_SZ_2048;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1282
			rctl &= ~E1000_RCTL_BSEX;
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_4096:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1285
			rctl |= E1000_RCTL_SZ_4096;
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_8192:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1288
			rctl |= E1000_RCTL_SZ_8192;
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
		case E1000_RXBUFFER_16384:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1291
			rctl |= E1000_RCTL_SZ_16384;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1292
			break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1293
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1294
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1295
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1296
#ifdef CONFIG_E1000_PACKET_SPLIT
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1297
	/* 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
  1298
	 * 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
  1299
	 * 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
  1300
	 * 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
  1301
	 * 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
  1302
	 * 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
  1303
	 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1304
	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
  1305
			  && (adapter->netdev->mtu 
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1306
	                      < ((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
  1307
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1308
	if(adapter->rx_ps) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1309
		/* Configure extra packet-split registers */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1310
		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
  1311
		rfctl |= E1000_RFCTL_EXTEN;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1312
		/* disable IPv6 packet split support */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1313
		rfctl |= E1000_RFCTL_IPV6_DIS;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1314
		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
  1315
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1316
		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
  1317
		
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1318
		psrctl |= adapter->rx_ps_bsize0 >>
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1319
			E1000_PSRCTL_BSIZE0_SHIFT;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1320
		psrctl |= PAGE_SIZE >>
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1321
			E1000_PSRCTL_BSIZE1_SHIFT;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1322
		psrctl |= PAGE_SIZE <<
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1323
			E1000_PSRCTL_BSIZE2_SHIFT;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1324
		psrctl |= PAGE_SIZE <<
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1325
			E1000_PSRCTL_BSIZE3_SHIFT;
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, PSRCTL, psrctl);
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
	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
  1331
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1332
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1333
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1334
 * 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
  1335
 * @adapter: board private structure
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
 * 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
  1338
 **/
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
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1341
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
  1342
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1343
	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
  1344
	uint32_t rdlen, rctl, rxcsum;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1345
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1346
	if(adapter->rx_ps) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1347
		rdlen = adapter->rx_ring.count *
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1348
			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
  1349
		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
  1350
		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
  1351
	} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1352
		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
  1353
		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
  1354
		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
  1355
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1356
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1357
	/* 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
  1358
	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
  1359
	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
  1360
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1361
	/* set the Receive Delay Timer Register */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1362
	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
  1363
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1364
	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
  1365
		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
  1366
		if(adapter->itr > 1)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1367
			E1000_WRITE_REG(&adapter->hw, ITR,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1368
				1000000000 / (adapter->itr * 256));
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1369
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1370
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1371
	/* 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
  1372
	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
  1373
	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
  1374
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1375
	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
  1376
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1377
	/* 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
  1378
	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
  1379
	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
  1380
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1381
	/* 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
  1382
	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
  1383
		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
  1384
		if(adapter->rx_csum == TRUE) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1385
			rxcsum |= E1000_RXCSUM_TUOFL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1386
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1387
			/* 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
  1388
			 * 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
  1389
			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
  1390
			   (adapter->rx_ps)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1391
				rxcsum |= E1000_RXCSUM_IPPCSE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1392
			}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1393
		} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1394
			rxcsum &= ~E1000_RXCSUM_TUOFL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1395
			/* 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
  1396
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1397
		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
  1398
	}
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
	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
  1401
		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
  1402
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1403
	/* Enable Receives */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1404
	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
  1405
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1406
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1407
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1408
 * 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
  1409
 * @adapter: board private structure
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
 * Free all transmit software resources
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1412
 **/
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
void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1415
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
  1416
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1417
	struct pci_dev *pdev = adapter->pdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1418
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1419
	e1000_clean_tx_ring(adapter);
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
	vfree(adapter->tx_ring.buffer_info);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1422
	adapter->tx_ring.buffer_info = NULL;
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
	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
  1425
	                    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
  1426
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1427
	adapter->tx_ring.desc = NULL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1428
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1429
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1430
static inline void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1431
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
  1432
			struct e1000_buffer *buffer_info)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1433
{
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  1434
	if (adapter->ecdev)
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  1435
		return;
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  1436
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1437
	if(buffer_info->dma) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1438
		pci_unmap_page(adapter->pdev,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1439
				buffer_info->dma,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1440
				buffer_info->length,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1441
				PCI_DMA_TODEVICE);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1442
		buffer_info->dma = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1443
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1444
	if(buffer_info->skb) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1445
		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
  1446
		buffer_info->skb = NULL;
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
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1449
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1450
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1451
 * 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
  1452
 * @adapter: board private structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1453
 **/
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
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1456
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
  1457
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1458
	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
  1459
	struct e1000_buffer *buffer_info;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1460
	unsigned long size;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1461
	unsigned int i;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1462
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1463
	/* 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
  1464
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1465
	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
  1466
		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
  1467
				&adapter->previous_buffer_info);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1468
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1469
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1470
	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
  1471
		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
  1472
		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
  1473
	}
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
	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
  1476
	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
  1477
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1478
	/* Zero out the descriptor ring */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1479
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1480
	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
  1481
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1482
	tx_ring->next_to_use = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1483
	tx_ring->next_to_clean = 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
	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
  1486
	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
  1487
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1488
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1489
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1490
 * 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
  1491
 * @adapter: board private structure
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
 * Free all receive software resources
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1494
 **/
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
void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1497
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
  1498
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1499
	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
  1500
	struct pci_dev *pdev = adapter->pdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1501
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1502
	e1000_clean_rx_ring(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1503
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1504
	vfree(rx_ring->buffer_info);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1505
	rx_ring->buffer_info = NULL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1506
	kfree(rx_ring->ps_page);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1507
	rx_ring->ps_page = NULL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1508
	kfree(rx_ring->ps_page_dma);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1509
	rx_ring->ps_page_dma = NULL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1510
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1511
	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
  1512
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1513
	rx_ring->desc = NULL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1514
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1515
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1516
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1517
 * 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
  1518
 * @adapter: board private structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1519
 **/
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
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1522
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
  1523
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1524
	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
  1525
	struct e1000_buffer *buffer_info;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1526
	struct e1000_ps_page *ps_page;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1527
	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
  1528
	struct pci_dev *pdev = adapter->pdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1529
	unsigned long size;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1530
	unsigned int i, j;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1531
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1532
	/* 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
  1533
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1534
	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
  1535
		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
  1536
		if(buffer_info->skb) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1537
			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
  1538
			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
  1539
			pci_unmap_single(pdev,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1540
					 buffer_info->dma,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1541
					 buffer_info->length,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1542
					 PCI_DMA_FROMDEVICE);
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
			dev_kfree_skb(buffer_info->skb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1545
			buffer_info->skb = NULL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1546
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1547
			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
  1548
				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
  1549
				pci_unmap_single(pdev,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1550
						 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
  1551
						 PAGE_SIZE, PCI_DMA_FROMDEVICE);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1552
				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
  1553
				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
  1554
				ps_page->ps_page[j] = NULL;
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
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1557
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1558
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1559
	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
  1560
	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
  1561
	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
  1562
	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
  1563
	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
  1564
	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
  1565
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1566
	/* Zero out the descriptor ring */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1567
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1568
	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
  1569
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1570
	rx_ring->next_to_clean = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1571
	rx_ring->next_to_use = 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
	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
  1574
	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
  1575
}
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
/* 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
  1578
 * 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
  1579
 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1580
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1581
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
  1582
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1583
	struct net_device *netdev = adapter->netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1584
	uint32_t rctl;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1585
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1586
	e1000_pci_clear_mwi(&adapter->hw);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1587
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1588
	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
  1589
	rctl |= E1000_RCTL_RST;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1590
	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
  1591
	E1000_WRITE_FLUSH(&adapter->hw);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1592
	mdelay(5);
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
	if (!adapter->ecdev && netif_running(netdev))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1595
		e1000_clean_rx_ring(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1596
}
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
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1599
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
  1600
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1601
	struct net_device *netdev = adapter->netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1602
	uint32_t rctl;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1603
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1604
	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
  1605
	rctl &= ~E1000_RCTL_RST;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1606
	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
  1607
	E1000_WRITE_FLUSH(&adapter->hw);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1608
	mdelay(5);
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->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
  1611
		e1000_pci_set_mwi(&adapter->hw);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1612
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1613
	if (!adapter->ecdev && netif_running(netdev)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1614
		e1000_configure_rx(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1615
		e1000_alloc_rx_buffers(adapter);
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
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1618
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1619
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1620
 * 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
  1621
 * @netdev: network interface device structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1622
 * @p: pointer to an address structure
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
 * 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
  1625
 **/
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
static int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1628
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
  1629
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1630
	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
  1631
	struct sockaddr *addr = p;
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
	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
  1634
		return -EADDRNOTAVAIL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1635
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1636
	/* 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
  1637
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1638
	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
  1639
		e1000_enter_82542_rst(adapter);
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
	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
  1642
	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
  1643
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1644
	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
  1645
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1646
	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
  1647
		e1000_leave_82542_rst(adapter);
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
	return 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1650
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1651
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1652
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1653
 * 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
  1654
 * @netdev: network interface device structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1655
 *
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1656
 * 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
  1657
 * 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
  1658
 * 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
  1659
 * promiscuous mode, and all-multi behavior.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1660
 **/
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
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1663
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
  1664
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1665
	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
  1666
	struct e1000_hw *hw = &adapter->hw;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1667
	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
  1668
	unsigned long flags = 0;
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1669
	uint32_t rctl;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1670
	uint32_t hash_value;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1671
	int i;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1672
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  1673
    if (!adapter->ecdev)
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  1674
        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
  1675
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1676
	/* 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
  1677
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1678
	rctl = E1000_READ_REG(hw, RCTL);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1679
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1680
	if(netdev->flags & IFF_PROMISC) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1681
		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
  1682
	} else if(netdev->flags & IFF_ALLMULTI) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1683
		rctl |= E1000_RCTL_MPE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1684
		rctl &= ~E1000_RCTL_UPE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1685
	} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1686
		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
  1687
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1688
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1689
	E1000_WRITE_REG(hw, RCTL, rctl);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1690
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1691
	/* 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
  1692
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1693
	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
  1694
		e1000_enter_82542_rst(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1695
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1696
	/* 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
  1697
	 * 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
  1698
	 * 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
  1699
	 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1700
	mc_ptr = netdev->mc_list;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1701
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1702
	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
  1703
		if(mc_ptr) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1704
			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
  1705
			mc_ptr = mc_ptr->next;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1706
		} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1707
			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
  1708
			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
  1709
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1710
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1711
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1712
	/* 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
  1713
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1714
	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
  1715
		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
  1716
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1717
	/* 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
  1718
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1719
	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
  1720
		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
  1721
		e1000_mta_set(hw, hash_value);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1722
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1723
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1724
	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
  1725
		e1000_leave_82542_rst(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1726
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  1727
    if (!adapter->ecdev)
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  1728
        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
  1729
}
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
/* 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
  1732
 * the phy */
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
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1735
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
  1736
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1737
	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
  1738
	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
  1739
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1740
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1741
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1742
 * 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
  1743
 * @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
  1744
 **/
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
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1747
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
  1748
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1749
	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
  1750
	struct net_device *netdev = adapter->netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1751
	uint32_t tctl;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1752
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1753
	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
  1754
		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
  1755
		    E1000_READ_REG(&adapter->hw, TDH)) &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1756
		   (E1000_READ_REG(&adapter->hw, TDFT) ==
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1757
		    E1000_READ_REG(&adapter->hw, TDFH)) &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1758
		   (E1000_READ_REG(&adapter->hw, TDFTS) ==
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1759
		    E1000_READ_REG(&adapter->hw, TDFHS))) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1760
			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
  1761
			E1000_WRITE_REG(&adapter->hw, TCTL,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1762
					tctl & ~E1000_TCTL_EN);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1763
			E1000_WRITE_REG(&adapter->hw, TDFT,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1764
					adapter->tx_head_addr);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1765
			E1000_WRITE_REG(&adapter->hw, TDFH,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1766
					adapter->tx_head_addr);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1767
			E1000_WRITE_REG(&adapter->hw, TDFTS,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1768
					adapter->tx_head_addr);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1769
			E1000_WRITE_REG(&adapter->hw, TDFHS,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1770
					adapter->tx_head_addr);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1771
			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
  1772
			E1000_WRITE_FLUSH(&adapter->hw);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1773
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1774
			adapter->tx_fifo_head = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1775
			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
  1776
			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
  1777
		} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1778
			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
  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
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1782
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1783
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1784
 * e1000_watchdog - Timer Call-back
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1785
 * @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
  1786
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1787
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1788
e1000_watchdog(unsigned long data)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1789
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1790
	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
  1791
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1792
	/* 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
  1793
	schedule_work(&adapter->watchdog_task);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1794
}
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
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1797
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
  1798
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1799
	struct net_device *netdev = adapter->netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1800
	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
  1801
	uint32_t link;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1802
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1803
	e1000_check_for_link(&adapter->hw);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1804
	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
  1805
		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
  1806
		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
  1807
			e1000_update_mng_vlan(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1808
	}	
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1809
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1810
	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
  1811
	   !(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
  1812
		link = !adapter->hw.serdes_link_down;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1813
	else
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1814
		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
  1815
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1816
	if (link) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1817
		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
  1818
				|| (!adapter->ecdev && !netif_carrier_ok(netdev))) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1819
			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
  1820
			                           &adapter->link_speed,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1821
			                           &adapter->link_duplex);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1822
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1823
			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
  1824
			       adapter->link_speed,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1825
			       adapter->link_duplex == FULL_DUPLEX ?
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1826
			       "Full Duplex" : "Half Duplex");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1827
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1828
			if (adapter->ecdev) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1829
				ecdev_set_link(adapter->ecdev, 1);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1830
			} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1831
				netif_carrier_on(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1832
				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
  1833
                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
  1834
			}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1835
			adapter->smartspeed = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1836
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1837
	} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1838
		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
  1839
				|| (!adapter->ecdev && netif_carrier_ok(netdev))) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1840
			adapter->link_speed = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1841
			adapter->link_duplex = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1842
			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
  1843
			if (adapter->ecdev) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1844
				ecdev_set_link(adapter->ecdev, 0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1845
			} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1846
				netif_carrier_off(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1847
				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
  1848
                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
  1849
			}
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_smartspeed(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
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1855
	e1000_update_stats(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1856
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1857
	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
  1858
	adapter->tpt_old = adapter->stats.tpt;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1859
	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
  1860
	adapter->colc_old = adapter->stats.colc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1861
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1862
	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
  1863
	adapter->gorcl_old = adapter->stats.gorcl;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1864
	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
  1865
	adapter->gotcl_old = adapter->stats.gotcl;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1866
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1867
	e1000_update_adaptive(&adapter->hw);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1868
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  1869
	if (!adapter->ecdev && !netif_carrier_ok(netdev)) {
677
7c7cf2d6c911 Minor changes.
Florian Pose <fp@igh-essen.com>
parents: 676
diff changeset
  1870
		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
  1871
			/* 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
  1872
			 * 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
  1873
			 * 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
  1874
			 * (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
  1875
			schedule_work(&adapter->tx_timeout_task);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1876
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1877
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1878
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1879
	/* 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
  1880
	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
  1881
		/* 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
  1882
		 * 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
  1883
		 * else is between 2000-8000. */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1884
		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
  1885
		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
  1886
			adapter->gotcl - adapter->gorcl :
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1887
			adapter->gorcl - adapter->gotcl) / 10000;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1888
		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
  1889
		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
  1890
	}
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
	/* 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
  1893
	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
  1894
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1895
	/* 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
  1896
	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
  1897
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1898
	/* 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
  1899
	if (!adapter->ecdev)
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  1900
        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
  1901
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1902
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1903
#define E1000_TX_FLAGS_CSUM		0x00000001
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1904
#define E1000_TX_FLAGS_VLAN		0x00000002
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1905
#define E1000_TX_FLAGS_TSO		0x00000004
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1906
#define E1000_TX_FLAGS_IPV4		0x00000008
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1907
#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
  1908
#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
  1909
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1910
static inline int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1911
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
  1912
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1913
#ifdef NETIF_F_TSO
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1914
	struct e1000_context_desc *context_desc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1915
	unsigned int i;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1916
	uint32_t cmd_length = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1917
	uint16_t ipcse = 0, tucse, mss;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1918
	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
  1919
	int err;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1920
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1921
	if(skb_shinfo(skb)->tso_size) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1922
		if (skb_header_cloned(skb)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1923
			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
  1924
			if (err)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1925
				return err;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1926
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1927
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1928
		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
  1929
		mss = skb_shinfo(skb)->tso_size;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1930
		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
  1931
			skb->nh.iph->tot_len = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1932
			skb->nh.iph->check = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1933
			skb->h.th->check =
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1934
				~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
  1935
						   skb->nh.iph->daddr,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1936
						   0,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1937
						   IPPROTO_TCP,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1938
						   0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1939
			cmd_length = E1000_TXD_CMD_IP;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1940
			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
  1941
#ifdef NETIF_F_TSO_IPV6
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1942
		} 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
  1943
			skb->nh.ipv6h->payload_len = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1944
			skb->h.th->check =
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1945
				~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
  1946
						 &skb->nh.ipv6h->daddr,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1947
						 0,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1948
						 IPPROTO_TCP,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1949
						 0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1950
			ipcse = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1951
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1952
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1953
		ipcss = skb->nh.raw - skb->data;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1954
		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
  1955
		tucss = skb->h.raw - skb->data;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1956
		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
  1957
		tucse = 0;
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
		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
  1960
			       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
  1961
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1962
		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
  1963
		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
  1964
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1965
		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
  1966
		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
  1967
		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
  1968
		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
  1969
		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
  1970
		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
  1971
		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
  1972
		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
  1973
		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
  1974
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1975
		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
  1976
		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
  1977
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1978
		return 1;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1979
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1980
#endif
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
	return 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1983
}
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
static inline boolean_t
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1986
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
  1987
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1988
	struct e1000_context_desc *context_desc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1989
	unsigned int i;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1990
	uint8_t css;
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
	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
  1993
		css = skb->h.raw - skb->data;
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
		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
  1996
		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
  1997
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1998
		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
  1999
		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
  2000
		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
  2001
		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
  2002
		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
  2003
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2004
		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
  2005
		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
  2006
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2007
		return TRUE;
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
	return FALSE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2011
}
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
#define E1000_MAX_TXD_PWR	12
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2014
#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
  2015
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2016
static inline int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2017
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
  2018
	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
  2019
	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
  2020
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2021
	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
  2022
	struct e1000_buffer *buffer_info;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2023
	unsigned int len = skb->len;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2024
	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
  2025
	unsigned int f;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2026
	len -= skb->data_len;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2027
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2028
	i = tx_ring->next_to_use;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2029
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2030
	while(len) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2031
		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
  2032
		size = min(len, max_per_txd);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2033
#ifdef NETIF_F_TSO
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2034
		/* Workaround for premature desc write-backs
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2035
		 * 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
  2036
		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
  2037
			size -= 4;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2038
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2039
		/* 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
  2040
		 * 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
  2041
		 * 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
  2042
		 * 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
  2043
		 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2044
		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
  2045
		                (size > 2015) && count == 0))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2046
		        size = 2015;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2047
                                                                                
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2048
		/* 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
  2049
		 * terminating buffers within evenly-aligned dwords. */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2050
		if(unlikely(adapter->pcix_82544 &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2051
		   !((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
  2052
		   size > 4))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2053
			size -= 4;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2054
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2055
		buffer_info->length = size;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2056
		buffer_info->dma =
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2057
			pci_map_single(adapter->pdev,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2058
				skb->data + offset,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2059
				size,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2060
				PCI_DMA_TODEVICE);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2061
		buffer_info->time_stamp = jiffies;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2062
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2063
		len -= size;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2064
		offset += size;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2065
		count++;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2066
		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
  2067
	}
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
	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
  2070
		struct skb_frag_struct *frag;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2071
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2072
		frag = &skb_shinfo(skb)->frags[f];
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2073
		len = frag->size;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2074
		offset = frag->page_offset;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2075
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2076
		while(len) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2077
			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
  2078
			size = min(len, max_per_txd);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2079
#ifdef NETIF_F_TSO
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2080
			/* Workaround for premature desc write-backs
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2081
			 * 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
  2082
			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
  2083
				size -= 4;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2084
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2085
			/* 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
  2086
			 * Avoid terminating buffers within evenly-aligned
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2087
			 * dwords. */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2088
			if(unlikely(adapter->pcix_82544 &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2089
			   !((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
  2090
			   size > 4))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2091
				size -= 4;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2092
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2093
			buffer_info->length = size;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2094
			buffer_info->dma =
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2095
				pci_map_page(adapter->pdev,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2096
					frag->page,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2097
					offset,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2098
					size,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2099
					PCI_DMA_TODEVICE);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2100
			buffer_info->time_stamp = jiffies;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2101
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2102
			len -= size;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2103
			offset += size;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2104
			count++;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2105
			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
  2106
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2107
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2108
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2109
	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
  2110
	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
  2111
	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
  2112
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2113
	return count;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2114
}
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
static inline void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2117
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
  2118
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2119
	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
  2120
	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
  2121
	struct e1000_buffer *buffer_info;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2122
	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
  2123
	unsigned int i;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2124
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2125
	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
  2126
		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
  2127
		             E1000_TXD_CMD_TSE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2128
		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
  2129
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2130
		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
  2131
			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
  2132
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2133
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2134
	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
  2135
		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
  2136
		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
  2137
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2138
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2139
	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
  2140
		txd_lower |= E1000_TXD_CMD_VLE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2141
		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
  2142
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2143
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2144
	i = tx_ring->next_to_use;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2145
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2146
	while(count--) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2147
		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
  2148
		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
  2149
		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
  2150
		tx_desc->lower.data =
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2151
			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
  2152
		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
  2153
		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
  2154
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2155
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2156
	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
  2157
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2158
	/* 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
  2159
	 * 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
  2160
	 * 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
  2161
	 * such as IA-64). */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2162
	wmb();
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
	tx_ring->next_to_use = i;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2165
	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
  2166
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2167
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2168
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2169
 * 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
  2170
 * 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
  2171
 * 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
  2172
 * 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
  2173
 * 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
  2174
 * 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
  2175
 **/
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
#define E1000_FIFO_HDR			0x10
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2178
#define E1000_82547_PAD_LEN		0x3E0
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
static inline int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2181
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
  2182
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2183
	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
  2184
	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
  2185
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2186
	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
  2187
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2188
	if(adapter->link_duplex != HALF_DUPLEX)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2189
		goto no_fifo_stall_required;
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(atomic_read(&adapter->tx_fifo_stall))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2192
		return 1;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2193
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2194
	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
  2195
		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
  2196
		return 1;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2197
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2198
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2199
no_fifo_stall_required:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2200
	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
  2201
	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
  2202
		adapter->tx_fifo_head -= adapter->tx_fifo_size;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2203
	return 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2204
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2205
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2206
#define MINIMUM_DHCP_PACKET_SIZE 282
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2207
static inline int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2208
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
  2209
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2210
	struct e1000_hw *hw =  &adapter->hw;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2211
	uint16_t length, offset;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2212
	if(vlan_tx_tag_present(skb)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2213
		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
  2214
			( adapter->hw.mng_cookie.status &
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2215
			  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
  2216
			return 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2217
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2218
	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
  2219
		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
  2220
		if(IPPROTO_UDP == ip->protocol) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2221
			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
  2222
			if(ntohs(udp->dest) == 67) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2223
				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
  2224
				length = skb->len - offset;
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
				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
  2227
						(uint8_t *)udp + 8, length);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2228
			}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2229
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2230
	} 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
  2231
		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
  2232
		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
  2233
			const struct iphdr *ip = 
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2234
				(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
  2235
			if(IPPROTO_UDP == ip->protocol) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2236
				struct udphdr *udp = 
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2237
					(struct udphdr *)((uint8_t *)ip + 
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2238
						(ip->ihl << 2));
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2239
				if(ntohs(udp->dest) == 67) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2240
					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
  2241
					length = skb->len - offset;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2242
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2243
					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
  2244
							(uint8_t *)udp + 8, 
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2245
							length);
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
			}
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
	return 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2251
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2252
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2253
#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
  2254
static int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2255
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
  2256
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2257
	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
  2258
	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
  2259
	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
  2260
	unsigned int tx_flags = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2261
	unsigned int len = skb->len;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2262
	unsigned long flags = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2263
	unsigned int nr_frags = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2264
	unsigned int mss = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2265
	int count = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2266
	int tso;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2267
	unsigned int f;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2268
	len -= skb->data_len;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2269
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2270
	if(unlikely(skb->len <= 0)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2271
		if (!adapter->ecdev)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2272
			dev_kfree_skb_any(skb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2273
		return NETDEV_TX_OK;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2274
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2275
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2276
#ifdef NETIF_F_TSO
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2277
	mss = skb_shinfo(skb)->tso_size;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2278
	/* 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
  2279
	 * 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
  2280
	 * 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
  2281
	 * 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
  2282
	 * 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
  2283
	 * drops. */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2284
	if(mss) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2285
		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
  2286
		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
  2287
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2288
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2289
	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
  2290
		count++;
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
#else
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2293
	if(skb->ip_summed == CHECKSUM_HW)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2294
		count++;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2295
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2296
	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
  2297
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2298
	if(adapter->pcix_82544)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2299
		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
	/* 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
  2302
	 * 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
  2303
	 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2304
	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
  2305
			(len > 2015)))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2306
		count++;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2307
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2308
	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
  2309
	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
  2310
		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
  2311
				       max_txd_pwr);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2312
	if(adapter->pcix_82544)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2313
		count += nr_frags;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2314
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2315
	if (!adapter->ecdev) {
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2316
		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
  2317
		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
  2318
			/* 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
  2319
			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
  2320
			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
  2321
		} 
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2322
		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
  2323
			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
  2324
	}
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2325
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2326
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2327
	/* 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
  2328
	 * head, otherwise try next time */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2329
	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
  2330
		if (!adapter->ecdev) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2331
			netif_stop_queue(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2332
			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
  2333
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2334
		return NETDEV_TX_BUSY;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2335
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2336
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2337
	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
  2338
		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
  2339
			if (!adapter->ecdev) {
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2340
				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
  2341
                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
  2342
				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
  2343
            }
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2344
			return NETDEV_TX_BUSY;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2345
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2346
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2347
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2348
	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
  2349
		tx_flags |= E1000_TX_FLAGS_VLAN;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2350
		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
  2351
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2352
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2353
	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
  2354
	
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2355
	tso = e1000_tso(adapter, skb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2356
	if (tso < 0) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2357
		if (!adapter->ecdev) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2358
			dev_kfree_skb_any(skb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2359
			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
  2360
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2361
		return NETDEV_TX_OK;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2362
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2363
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2364
	if (likely(tso))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2365
		tx_flags |= E1000_TX_FLAGS_TSO;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2366
	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
  2367
		tx_flags |= E1000_TX_FLAGS_CSUM;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2368
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2369
	/* 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
  2370
	 * 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
  2371
	 * no longer assume, we must. */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2372
	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
  2373
		tx_flags |= E1000_TX_FLAGS_IPV4;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2374
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2375
	e1000_tx_queue(adapter,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2376
		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
  2377
		tx_flags);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2378
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2379
	netdev->trans_start = jiffies;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2380
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2381
	/* 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
  2382
	if (!adapter->ecdev) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2383
		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
  2384
			netif_stop_queue(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2385
		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
  2386
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2387
	return NETDEV_TX_OK;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2388
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2389
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2390
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2391
 * 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
  2392
 * @netdev: network interface device structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2393
 **/
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
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2396
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
  2397
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2398
	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
  2399
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2400
	/* 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
  2401
	schedule_work(&adapter->tx_timeout_task);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2402
}
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
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2405
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
  2406
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2407
	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
  2408
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2409
	e1000_down(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2410
	e1000_up(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2411
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2412
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2413
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2414
 * 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
  2415
 * @netdev: network interface device structure
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
 * 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
  2418
 * 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
  2419
 **/
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
static struct net_device_stats *
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2422
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
  2423
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2424
	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
  2425
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2426
	e1000_update_stats(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2427
	return &adapter->net_stats;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2428
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2429
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2430
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2431
 * 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
  2432
 * @netdev: network interface device structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2433
 * @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
  2434
 *
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2435
 * 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
  2436
 **/
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
static int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2439
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
  2440
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2441
	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
  2442
	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
  2443
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2444
	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
  2445
		(max_frame > MAX_JUMBO_FRAME_SIZE)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2446
			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
  2447
			return -EINVAL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2448
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2449
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2450
#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
  2451
	/* 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
  2452
	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
  2453
	    max_frame > MAXIMUM_ETHERNET_FRAME_SIZE) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2454
		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
  2455
				    "on 82573\n");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2456
		return -EINVAL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2457
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2458
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2459
	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
  2460
		adapter->rx_buffer_len = max_frame;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2461
		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
  2462
	} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2463
		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
  2464
		   (max_frame > MAXIMUM_ETHERNET_FRAME_SIZE))) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2465
			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
  2466
					    "on 82542\n");
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2467
			return -EINVAL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2468
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2469
		} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2470
			if(max_frame <= E1000_RXBUFFER_2048) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2471
				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
  2472
			} 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
  2473
				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
  2474
			} 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
  2475
				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
  2476
			} 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
  2477
				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
  2478
			}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2479
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2480
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2481
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2482
	netdev->mtu = new_mtu;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2483
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2484
	if (adapter->ecdev || netif_running(netdev)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2485
		e1000_down(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2486
		e1000_up(adapter);
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
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2489
	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
  2490
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2491
	return 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2492
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2493
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2494
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2495
 * 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
  2496
 * @adapter: board private structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2497
 **/
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
void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2500
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
  2501
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2502
	struct e1000_hw *hw = &adapter->hw;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2503
	unsigned long flags = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2504
	uint16_t phy_tmp;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2505
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2506
#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
  2507
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2508
	if (!adapter->ecdev)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2509
		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
  2510
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2511
	/* 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
  2512
	 * 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
  2513
	 * 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
  2514
	 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2515
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2516
	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
  2517
	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
  2518
	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
  2519
	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
  2520
	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
  2521
	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
  2522
	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
  2523
	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
  2524
	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
  2525
	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
  2526
	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
  2527
	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
  2528
	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
  2529
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2530
	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
  2531
	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
  2532
	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
  2533
	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
  2534
	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
  2535
	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
  2536
	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
  2537
	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
  2538
	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
  2539
	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
  2540
	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
  2541
	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
  2542
	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
  2543
	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
  2544
	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
  2545
	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
  2546
	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
  2547
	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
  2548
	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
  2549
	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
  2550
	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
  2551
	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
  2552
	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
  2553
	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
  2554
	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
  2555
	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
  2556
	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
  2557
	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
  2558
	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
  2559
	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
  2560
	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
  2561
	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
  2562
	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
  2563
	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
  2564
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2565
	/* used for adaptive IFS */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2566
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2567
	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
  2568
	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
  2569
	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
  2570
	adapter->stats.colc += hw->collision_delta;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2571
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2572
	if(hw->mac_type >= e1000_82543) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2573
		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
  2574
		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
  2575
		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
  2576
		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
  2577
		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
  2578
		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
  2579
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2580
	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
  2581
		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
  2582
		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
  2583
		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
  2584
		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
  2585
		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
  2586
		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
  2587
		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
  2588
		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
  2589
		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
  2590
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2591
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2592
	/* Fill out the OS statistics structure */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2593
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2594
	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
  2595
	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
  2596
	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
  2597
	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
  2598
	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
  2599
	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
  2600
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2601
	/* Rx Errors */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2602
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2603
	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
  2604
		adapter->stats.crcerrs + adapter->stats.algnerrc +
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2605
		adapter->stats.rlec + adapter->stats.mpc + 
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2606
		adapter->stats.cexterr;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2607
	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
  2608
	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
  2609
	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
  2610
	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
  2611
	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
  2612
	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
  2613
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2614
	/* Tx Errors */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2615
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2616
	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
  2617
	                               adapter->stats.latecol;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2618
	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
  2619
	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
  2620
	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
  2621
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2622
	/* 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
  2623
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2624
	/* Phy Stats */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2625
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2626
	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
  2627
		if((adapter->link_speed == SPEED_1000) &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2628
		   (!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
  2629
			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
  2630
			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
  2631
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2632
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2633
		if((hw->mac_type <= e1000_82546) &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2634
		   (hw->phy_type == e1000_phy_m88) &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2635
		   !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
  2636
			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
  2637
	}
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
	if (!adapter->ecdev)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2640
		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
  2641
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2642
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2643
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
  2644
{
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2645
    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
  2646
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2647
    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
  2648
        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
  2649
        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
  2650
    }
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2651
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2652
    e1000_intr(0, netdev, NULL);
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2653
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2654
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2655
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2656
 * e1000_intr - Interrupt Handler
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2657
 * @irq: interrupt number
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2658
 * @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
  2659
 * @pt_regs: CPU registers structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2660
 **/
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
static irqreturn_t
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2663
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
  2664
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2665
	struct net_device *netdev = data;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2666
	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
  2667
	struct e1000_hw *hw = &adapter->hw;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2668
	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
  2669
	unsigned int i;
727
fc533d28c6f8 Fixed e1000 driver when NAPI is enabled.
Florian Pose <fp@igh-essen.com>
parents: 724
diff changeset
  2670
#ifdef CONFIG_E1000_NAPI
fc533d28c6f8 Fixed e1000 driver when NAPI is enabled.
Florian Pose <fp@igh-essen.com>
parents: 724
diff changeset
  2671
	int work_done = 0;
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2672
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2674
	if(unlikely(!icr))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2675
		return IRQ_NONE;  /* Not our interrupt */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2676
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2677
	if(unlikely(icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC))) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2678
		hw->get_link_status = 1;
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2679
		if (!adapter->ecdev)
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2680
            mod_timer(&adapter->watchdog_timer, jiffies);
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2681
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2682
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2683
#ifdef CONFIG_E1000_NAPI
727
fc533d28c6f8 Fixed e1000 driver when NAPI is enabled.
Florian Pose <fp@igh-essen.com>
parents: 724
diff changeset
  2684
	if (adapter->ecdev) {
fc533d28c6f8 Fixed e1000 driver when NAPI is enabled.
Florian Pose <fp@igh-essen.com>
parents: 724
diff changeset
  2685
		for(i = 0; i < E1000_MAX_INTR; i++)
2050
a3e59f2a8589 Changed accidentally used & operator to &&.
Florian Pose <fp@igh-essen.com>
parents: 1325
diff changeset
  2686
			if(unlikely(!adapter->clean_rx(adapter, &work_done, 100) &&
727
fc533d28c6f8 Fixed e1000 driver when NAPI is enabled.
Florian Pose <fp@igh-essen.com>
parents: 724
diff changeset
  2687
						!e1000_clean_tx_irq(adapter)))
fc533d28c6f8 Fixed e1000 driver when NAPI is enabled.
Florian Pose <fp@igh-essen.com>
parents: 724
diff changeset
  2688
				break;
fc533d28c6f8 Fixed e1000 driver when NAPI is enabled.
Florian Pose <fp@igh-essen.com>
parents: 724
diff changeset
  2689
	} else {
fc533d28c6f8 Fixed e1000 driver when NAPI is enabled.
Florian Pose <fp@igh-essen.com>
parents: 724
diff changeset
  2690
		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
  2691
fc533d28c6f8 Fixed e1000 driver when NAPI is enabled.
Florian Pose <fp@igh-essen.com>
parents: 724
diff changeset
  2692
			/* 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
  2693
			   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
  2694
			 */
fc533d28c6f8 Fixed e1000 driver when NAPI is enabled.
Florian Pose <fp@igh-essen.com>
parents: 724
diff changeset
  2695
fc533d28c6f8 Fixed e1000 driver when NAPI is enabled.
Florian Pose <fp@igh-essen.com>
parents: 724
diff changeset
  2696
			atomic_inc(&adapter->irq_sem);
fc533d28c6f8 Fixed e1000 driver when NAPI is enabled.
Florian Pose <fp@igh-essen.com>
parents: 724
diff changeset
  2697
			E1000_WRITE_REG(hw, IMC, ~0);
fc533d28c6f8 Fixed e1000 driver when NAPI is enabled.
Florian Pose <fp@igh-essen.com>
parents: 724
diff changeset
  2698
			__netif_rx_schedule(netdev);
fc533d28c6f8 Fixed e1000 driver when NAPI is enabled.
Florian Pose <fp@igh-essen.com>
parents: 724
diff changeset
  2699
		}
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2700
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2701
#else
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2702
	/* 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
  2703
	   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
  2704
	   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
  2705
	   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
  2706
	   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
  2707
	   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
  2708
	   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
  2709
	   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
  2710
	   de-assertion state.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2711
	*/
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2712
	if(!adapter->ecdev &&
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2713
			(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
  2714
		atomic_inc(&adapter->irq_sem);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2715
		E1000_WRITE_REG(hw, IMC, ~0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2716
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2717
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2718
	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
  2719
		if(unlikely(!adapter->clean_rx(adapter) &
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2720
		   !e1000_clean_tx_irq(adapter)))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2721
			break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2722
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2723
	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
  2724
		e1000_irq_enable(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2725
#endif
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
	return IRQ_HANDLED;
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
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2730
#ifdef CONFIG_E1000_NAPI
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
 * e1000_clean - NAPI Rx polling callback
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2733
 * @adapter: board private structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2734
 **/
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
static int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2737
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
  2738
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2739
	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
  2740
	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
  2741
	int tx_cleaned;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2742
	int work_done = 0;
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
	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
  2745
	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
  2746
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2747
	*budget -= work_done;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2748
	netdev->quota -= work_done;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2749
	
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2750
	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
  2751
	/* 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
  2752
		netif_rx_complete(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2753
		e1000_irq_enable(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2754
		return 0;
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
	return 1;
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
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2760
#endif
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
 * 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
  2763
 * @adapter: board private structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2764
 **/
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
static boolean_t
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2767
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
  2768
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2769
	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
  2770
	struct net_device *netdev = adapter->netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2771
	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
  2772
	struct e1000_buffer *buffer_info;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2773
	unsigned int i, eop;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2774
	boolean_t cleaned = FALSE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2775
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2776
	i = tx_ring->next_to_clean;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2777
	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
  2778
	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
  2779
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2780
	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
  2781
		/* 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
  2782
		 * 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
  2783
		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
  2784
			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
  2785
					&adapter->previous_buffer_info);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2786
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2787
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2788
		for(cleaned = FALSE; !cleaned; ) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2789
			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
  2790
			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
  2791
			cleaned = (i == eop);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2792
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2793
#ifdef NETIF_F_TSO
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2794
			if (!(netdev->features & NETIF_F_TSO)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2795
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2796
				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
  2797
				                                 buffer_info);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2798
#ifdef NETIF_F_TSO
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2799
			} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2800
				if (cleaned) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2801
					memcpy(&adapter->previous_buffer_info,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2802
					       buffer_info,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2803
					       sizeof(struct e1000_buffer));
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2804
					memset(buffer_info, 0,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2805
					       sizeof(struct e1000_buffer));
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2806
				} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2807
					e1000_unmap_and_free_tx_resource(
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2808
					    adapter, buffer_info);
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
			}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2811
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2812
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2813
			tx_desc->buffer_addr = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2814
			tx_desc->lower.data = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2815
			tx_desc->upper.data = 0;
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
			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
  2818
		}
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
		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
  2821
		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
  2822
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2823
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2824
	tx_ring->next_to_clean = i;
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 (!adapter->ecdev) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2827
		spin_lock(&adapter->tx_lock);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2828
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2829
		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
  2830
					netif_carrier_ok(netdev)))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2831
			netif_wake_queue(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2832
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2833
		spin_unlock(&adapter->tx_lock);
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
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  2836
	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
  2837
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2838
		/* 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
  2839
		 * 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
  2840
		adapter->detect_tx_hung = FALSE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2841
		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
  2842
		    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
  2843
		    && !(E1000_READ_REG(&adapter->hw, STATUS) &
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2844
			E1000_STATUS_TXOFF)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2845
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2846
			/* detected Tx unit hang */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2847
			i = tx_ring->next_to_clean;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2848
			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
  2849
			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
  2850
			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
  2851
					"  TDH                  <%x>\n"
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2852
					"  TDT                  <%x>\n"
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2853
					"  next_to_use          <%x>\n"
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2854
					"  next_to_clean        <%x>\n"
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2855
					"buffer_info[next_to_clean]\n"
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2856
					"  dma                  <%zx>\n"
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2857
					"  time_stamp           <%lx>\n"
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2858
					"  next_to_watch        <%x>\n"
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2859
					"  jiffies              <%lx>\n"
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2860
					"  next_to_watch.status <%x>\n",
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2861
				E1000_READ_REG(&adapter->hw, TDH),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2862
				E1000_READ_REG(&adapter->hw, TDT),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2863
				tx_ring->next_to_use,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2864
				i,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2865
				tx_ring->buffer_info[i].dma,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2866
				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
  2867
				eop,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2868
				jiffies,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2869
				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
  2870
			netif_stop_queue(netdev);
673
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
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2873
#ifdef NETIF_F_TSO
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2874
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2875
	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
  2876
	    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
  2877
		e1000_unmap_and_free_tx_resource(
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2878
		    adapter, &adapter->previous_buffer_info);
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
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2881
	return cleaned;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2882
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2883
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2884
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2885
 * 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
  2886
 * @adapter:     board private structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2887
 * @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
  2888
 * @csum:        receive descriptor csum field
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2889
 * @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
  2890
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2891
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2892
static inline void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2893
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
  2894
		  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
  2895
		  struct sk_buff *skb)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2896
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2897
	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
  2898
	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
  2899
	skb->ip_summed = CHECKSUM_NONE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2900
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2901
	/* 82543 or newer only */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2902
	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
  2903
	/* Ignore Checksum bit is set */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2904
	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
  2905
	/* 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
  2906
	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
  2907
		/* let the stack verify checksum errors */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2908
		adapter->hw_csum_err++;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2909
		return;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2910
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2911
	/* 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
  2912
	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
  2913
		if(!(status & E1000_RXD_STAT_TCPCS))
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
	} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2916
		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
  2917
			return;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2918
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2919
	/* 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
  2920
	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
  2921
		/* TCP checksum is good */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2922
		skb->ip_summed = CHECKSUM_UNNECESSARY;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2923
	} 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
  2924
		/* IP fragment with UDP payload */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2925
		/* 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
  2926
		 * 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
  2927
		 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2928
		csum = ntohl(csum ^ 0xFFFF);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2929
		skb->csum = csum;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2930
		skb->ip_summed = CHECKSUM_HW;
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
	adapter->hw_csum_good++;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2933
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2934
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
 * 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
  2937
 * @adapter: board private structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2938
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2939
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2940
static boolean_t
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2941
#ifdef CONFIG_E1000_NAPI
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, int *work_done,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2943
                   int work_to_do)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2944
#else
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2945
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
  2946
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2947
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2948
	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
  2949
	struct net_device *netdev = adapter->netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2950
	struct pci_dev *pdev = adapter->pdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2951
	struct e1000_rx_desc *rx_desc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2952
	struct e1000_buffer *buffer_info;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2953
	struct sk_buff *skb;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2954
	unsigned long flags;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2955
	uint32_t length;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2956
	uint8_t last_byte;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2957
	unsigned int i;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2958
	boolean_t cleaned = FALSE;
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
	i = rx_ring->next_to_clean;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2961
	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
  2962
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2963
	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
  2964
		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
  2965
#ifdef CONFIG_E1000_NAPI
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2966
		if(*work_done >= work_to_do)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2967
			break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2968
		(*work_done)++;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2969
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2970
		cleaned = TRUE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2971
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2972
		pci_unmap_single(pdev,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2973
		                 buffer_info->dma,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2974
		                 buffer_info->length,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2975
		                 PCI_DMA_FROMDEVICE);
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
		skb = buffer_info->skb;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2978
		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
  2979
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2980
		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
  2981
			/* 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
  2982
			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
  2983
				  " buffers\n", netdev->name);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2984
			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
  2985
			goto next_desc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2986
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2987
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2988
		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
  2989
			last_byte = *(skb->data + length - 1);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2990
			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
  2991
			              rx_desc->errors, length, last_byte)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2992
				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
  2993
				e1000_tbi_adjust_stats(&adapter->hw,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2994
				                       &adapter->stats,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2995
				                       length, skb->data);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2996
				spin_unlock_irqrestore(&adapter->stats_lock,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2997
				                       flags);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2998
				length--;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2999
			} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3000
				dev_kfree_skb_irq(skb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3001
				goto next_desc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3002
			}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3003
		}
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
		/* Good Receive */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3006
		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
  3007
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3008
		/* Receive Checksum Offload */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3009
		e1000_rx_checksum(adapter,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3010
				  (uint32_t)(rx_desc->status) |
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3011
				  ((uint32_t)(rx_desc->errors) << 24),
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3012
				  rx_desc->csum, skb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3013
		if (adapter->ecdev) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3014
			ecdev_receive(adapter->ecdev, skb->data, length);
1152
30f168c7f74f No need to call e1000 watchdog when frames are received (thanks to O. Zarges).
Florian Pose <fp@igh-essen.com>
parents: 1011
diff changeset
  3015
30f168c7f74f No need to call e1000 watchdog when frames are received (thanks to O. Zarges).
Florian Pose <fp@igh-essen.com>
parents: 1011
diff changeset
  3016
			// No need to detect link status as
30f168c7f74f No need to call e1000 watchdog when frames are received (thanks to O. Zarges).
Florian Pose <fp@igh-essen.com>
parents: 1011
diff changeset
  3017
			// long as frames are received: Reset watchdog.
30f168c7f74f No need to call e1000 watchdog when frames are received (thanks to O. Zarges).
Florian Pose <fp@igh-essen.com>
parents: 1011
diff changeset
  3018
			adapter->ec_watchdog_jiffies = jiffies;
30f168c7f74f No need to call e1000 watchdog when frames are received (thanks to O. Zarges).
Florian Pose <fp@igh-essen.com>
parents: 1011
diff changeset
  3019
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3020
			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
  3021
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3022
			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
  3023
				/* 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
  3024
				 * 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
  3025
				 * 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
  3026
				 * 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
  3027
				wmb();
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3028
				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
  3029
			}
673
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
			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
  3032
#ifdef CONFIG_E1000_NAPI
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3033
			if(unlikely(adapter->vlgrp &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3034
						(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
  3035
				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
  3036
						le16_to_cpu(rx_desc->special) &
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3037
						E1000_RXD_SPC_VLAN_MASK);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3038
			} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3039
				netif_receive_skb(skb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3040
			}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3041
#else /* CONFIG_E1000_NAPI */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3042
			if(unlikely(adapter->vlgrp &&
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3043
						(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
  3044
				vlan_hwaccel_rx(skb, adapter->vlgrp,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3045
						le16_to_cpu(rx_desc->special) &
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3046
						E1000_RXD_SPC_VLAN_MASK);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3047
			} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3048
				netif_rx(skb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3049
			}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3050
#endif /* CONFIG_E1000_NAPI */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3051
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3052
		netdev->last_rx = jiffies;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3053
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3054
next_desc:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3055
		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
  3056
		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
  3057
		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
  3058
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3059
		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
  3060
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3061
	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
  3062
	if (adapter->ecdev) {
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3063
		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
  3064
	} else {
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3065
		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
  3066
	}
673
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
	return cleaned;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3069
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3070
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3071
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3072
 * 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
  3073
 * @adapter: board private structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3074
 **/
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
static boolean_t
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3077
#ifdef CONFIG_E1000_NAPI
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3078
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
  3079
                      int work_to_do)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3080
#else
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3081
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
  3082
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3083
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3084
	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
  3085
	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
  3086
	struct net_device *netdev = adapter->netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3087
	struct pci_dev *pdev = adapter->pdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3088
	struct e1000_buffer *buffer_info;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3089
	struct e1000_ps_page *ps_page;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3090
	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
  3091
	struct sk_buff *skb;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3092
	unsigned int i, j;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3093
	uint32_t length, staterr;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3094
	boolean_t cleaned = FALSE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3095
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3096
	i = rx_ring->next_to_clean;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3097
	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
  3098
	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
  3099
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3100
	while(staterr & E1000_RXD_STAT_DD) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3101
		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
  3102
		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
  3103
		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
  3104
#ifdef CONFIG_E1000_NAPI
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3105
		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
  3106
			break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3107
		(*work_done)++;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3108
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3109
		cleaned = TRUE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3110
		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
  3111
				 buffer_info->length,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3112
				 PCI_DMA_FROMDEVICE);
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
		skb = buffer_info->skb;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3115
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3116
		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
  3117
			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
  3118
				  " the full packet\n", netdev->name);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3119
			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
  3120
			goto next_desc;
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
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3123
		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
  3124
			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
  3125
			goto next_desc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3126
		}
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
		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
  3129
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3130
		if(unlikely(!length)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3131
			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
  3132
				  " multiple descriptors\n", netdev->name);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3133
			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
  3134
			goto next_desc;
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
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3137
		/* Good Receive */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3138
		skb_put(skb, length);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3139
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3140
		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
  3141
			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
  3142
				break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3143
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3144
			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
  3145
					PAGE_SIZE, PCI_DMA_FROMDEVICE);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3146
			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
  3147
			skb_shinfo(skb)->frags[j].page =
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3148
				ps_page->ps_page[j];
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3149
			ps_page->ps_page[j] = NULL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3150
			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
  3151
			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
  3152
			skb_shinfo(skb)->nr_frags++;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3153
			skb->len += length;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3154
			skb->data_len += length;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3155
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3156
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3157
		e1000_rx_checksum(adapter, staterr,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3158
				  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
  3159
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3160
#ifdef HAVE_RX_ZERO_COPY
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3161
		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
  3162
			  E1000_RXDPS_HDRSTAT_HDRSP))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3163
			skb_shinfo(skb)->zero_copy = TRUE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3164
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3165
		if (adapter->ecdev) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3166
			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
  3167
			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
  3168
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3169
			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
  3170
				/* 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
  3171
				 * 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
  3172
				 * 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
  3173
				 * 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
  3174
				wmb();
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3175
				/* 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
  3176
				 * 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
  3177
				 * twice as much.
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3178
				 */
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3179
				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
  3180
			}
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3181
		} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3182
			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
  3183
#ifdef 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_receive_skb(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_receive_skb(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
#else /* CONFIG_E1000_NAPI */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3192
			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
  3193
				vlan_hwaccel_rx(skb, adapter->vlgrp,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3194
						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
  3195
						E1000_RXD_SPC_VLAN_MASK);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3196
			} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3197
				netif_rx(skb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3198
			}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3199
#endif /* CONFIG_E1000_NAPI */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3200
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3201
		netdev->last_rx = jiffies;
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
next_desc:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3204
		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
  3205
		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
  3206
		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
  3207
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3208
		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
  3209
		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
  3210
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3211
	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
  3212
	if (adapter->ecdev) { 
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3213
		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
  3214
	} else {
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3215
		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
  3216
	}
673
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
	return cleaned;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3219
}
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
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3222
 * 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
  3223
 * @adapter: address of board private structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3224
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3225
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3226
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3227
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
  3228
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3229
	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
  3230
	struct net_device *netdev = adapter->netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3231
	struct pci_dev *pdev = adapter->pdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3232
	struct e1000_rx_desc *rx_desc;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3233
	struct e1000_buffer *buffer_info;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3234
	struct sk_buff *skb;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3235
	unsigned int i;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3236
	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
  3237
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3238
	i = rx_ring->next_to_use;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3239
	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
  3240
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3241
	while(!buffer_info->skb) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3242
		skb = dev_alloc_skb(bufsz);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3243
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3244
		if(unlikely(!skb)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3245
			/* Better luck next round */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3246
			break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3247
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3248
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3249
		/* 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
  3250
		if (!e1000_check_64k_bound(adapter, skb->data, bufsz)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3251
			struct sk_buff *oldskb = skb;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3252
			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
  3253
					     "at %p\n", bufsz, skb->data);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3254
			/* Try again, without freeing the previous */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3255
			skb = dev_alloc_skb(bufsz);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3256
			/* Failed allocation, critical failure */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3257
			if (!skb) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3258
				dev_kfree_skb(oldskb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3259
				break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3260
			}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3261
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3262
			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
  3263
				/* give up */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3264
				dev_kfree_skb(skb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3265
				dev_kfree_skb(oldskb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3266
				break; /* while !buffer_info->skb */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3267
			} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3268
				/* Use new allocation */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3269
				dev_kfree_skb(oldskb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3270
			}
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
		/* 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
  3273
		 * 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
  3274
		 * 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
  3275
		 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3276
		skb_reserve(skb, NET_IP_ALIGN);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3277
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3278
		skb->dev = netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3279
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3280
		buffer_info->skb = skb;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3281
		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
  3282
		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
  3283
						  skb->data,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3284
						  adapter->rx_buffer_len,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3285
						  PCI_DMA_FROMDEVICE);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3286
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3287
		/* 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
  3288
		if (!e1000_check_64k_bound(adapter,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3289
					(void *)(unsigned long)buffer_info->dma,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3290
					adapter->rx_buffer_len)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3291
			DPRINTK(RX_ERR, ERR,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3292
				"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
  3293
				adapter->rx_buffer_len,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3294
				(void *)(unsigned long)buffer_info->dma);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3295
			dev_kfree_skb(skb);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3296
			buffer_info->skb = NULL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3297
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3298
			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
  3299
					 adapter->rx_buffer_len,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3300
					 PCI_DMA_FROMDEVICE);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3301
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3302
			break; /* while !buffer_info->skb */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3303
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3304
		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
  3305
		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
  3306
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3307
		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
  3308
			/* 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
  3309
			 * 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
  3310
			 * 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
  3311
			 * such as IA-64). */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3312
			wmb();
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3313
			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
  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
		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
  3317
		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
  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
	rx_ring->next_to_use = i;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3321
}
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
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3324
 * 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
  3325
 * @adapter: address of board private structure
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3326
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3327
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3328
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3329
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
  3330
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3331
	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
  3332
	struct net_device *netdev = adapter->netdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3333
	struct pci_dev *pdev = adapter->pdev;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3334
	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
  3335
	struct e1000_buffer *buffer_info;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3336
	struct e1000_ps_page *ps_page;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3337
	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
  3338
	struct sk_buff *skb;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3339
	unsigned int i, j;
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
	i = rx_ring->next_to_use;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3342
	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
  3343
	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
  3344
	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
  3345
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3346
	while(!buffer_info->skb) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3347
		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
  3348
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3349
		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
  3350
			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
  3351
				ps_page->ps_page[j] =
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3352
					alloc_page(GFP_ATOMIC);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3353
				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
  3354
					goto no_buffers;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3355
				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
  3356
					pci_map_page(pdev,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3357
						     ps_page->ps_page[j],
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3358
						     0, PAGE_SIZE,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3359
						     PCI_DMA_FROMDEVICE);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3360
			}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3361
			/* 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
  3362
			 * 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
  3363
			 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3364
			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
  3365
				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
  3366
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3367
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3368
		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
  3369
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3370
		if(unlikely(!skb))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3371
			break;
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
		/* 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
  3374
		 * 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
  3375
		 * 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
  3376
		 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3377
		skb_reserve(skb, NET_IP_ALIGN);
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
		skb->dev = netdev;
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
		buffer_info->skb = skb;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3382
		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
  3383
		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
  3384
						  adapter->rx_ps_bsize0,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3385
						  PCI_DMA_FROMDEVICE);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3386
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3387
		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
  3388
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3389
		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
  3390
			/* 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
  3391
			 * 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
  3392
			 * 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
  3393
			 * such as IA-64). */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3394
			wmb();
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3395
			/* 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
  3396
			 * 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
  3397
			 * twice as much.
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
			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
  3400
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3401
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3402
		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
  3403
		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
  3404
		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
  3405
		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
  3406
	}
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
no_buffers:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3409
	rx_ring->next_to_use = i;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3410
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3411
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3412
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3413
 * 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
  3414
 * @adapter:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3415
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3416
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3417
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3418
e1000_smartspeed(struct e1000_adapter *adapter)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3419
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3420
	uint16_t phy_status;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3421
	uint16_t phy_ctrl;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3422
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3423
	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
  3424
	   !(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
  3425
		return;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3426
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3427
	if(adapter->smartspeed == 0) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3428
		/* 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
  3429
		 * we assume back-to-back */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3430
		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
  3431
		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
  3432
		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
  3433
		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
  3434
		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
  3435
		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
  3436
			phy_ctrl &= ~CR_1000T_MS_ENABLE;
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_1000T_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
			adapter->smartspeed++;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3440
			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
  3441
			   !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
  3442
				   	       &phy_ctrl)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3443
				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
  3444
					     MII_CR_RESTART_AUTO_NEG);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3445
				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
  3446
						    phy_ctrl);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3447
			}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3448
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3449
		return;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3450
	} 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
  3451
		/* 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
  3452
		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
  3453
		phy_ctrl |= CR_1000T_MS_ENABLE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3454
		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
  3455
		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
  3456
		   !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
  3457
			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
  3458
				     MII_CR_RESTART_AUTO_NEG);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3459
			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
  3460
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3461
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3462
	/* 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
  3463
	if(adapter->smartspeed++ == E1000_SMARTSPEED_MAX)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3464
		adapter->smartspeed = 0;
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
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3467
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3468
 * e1000_ioctl -
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3469
 * @netdev:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3470
 * @ifreq:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3471
 * @cmd:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3472
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3473
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3474
static int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3475
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
  3476
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3477
	switch (cmd) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3478
	case SIOCGMIIPHY:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3479
	case SIOCGMIIREG:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3480
	case SIOCSMIIREG:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3481
		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
  3482
	default:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3483
		return -EOPNOTSUPP;
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
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3487
/**
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3488
 * e1000_mii_ioctl -
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3489
 * @netdev:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3490
 * @ifreq:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3491
 * @cmd:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3492
 **/
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3493
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3494
static int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3495
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
  3496
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3497
	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
  3498
	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
  3499
	int retval;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3500
	uint16_t mii_reg;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3501
	uint16_t spddplx;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3502
	unsigned long flags;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3503
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3504
	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
  3505
		return -EOPNOTSUPP;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3506
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3507
	switch (cmd) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3508
	case SIOCGMIIPHY:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3509
		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
  3510
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3511
	case SIOCGMIIREG:
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3512
		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
  3513
			return -EPERM;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3514
		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
  3515
		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
  3516
				   &data->val_out)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3517
			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
  3518
			return -EIO;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3519
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3520
		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
  3521
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3522
	case SIOCSMIIREG:
676
aa394dc1943a First working version of e1000 driver under 2.6.13.
Florian Pose <fp@igh-essen.com>
parents: 673
diff changeset
  3523
		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
  3524
			return -EPERM;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3525
		if(data->reg_num & ~(0x1F))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3526
			return -EFAULT;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3527
		mii_reg = data->val_in;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3528
		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
  3529
		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
  3530
					mii_reg)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3531
			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
  3532
			return -EIO;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3533
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3534
		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
  3535
			switch (data->reg_num) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3536
			case PHY_CTRL:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3537
				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
  3538
					break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3539
				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
  3540
					adapter->hw.autoneg = 1;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3541
					adapter->hw.autoneg_advertised = 0x2F;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3542
				} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3543
					if (mii_reg & 0x40)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3544
						spddplx = SPEED_1000;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3545
					else if (mii_reg & 0x2000)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3546
						spddplx = SPEED_100;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3547
					else
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3548
						spddplx = SPEED_10;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3549
					spddplx += (mii_reg & 0x100)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3550
						   ? FULL_DUPLEX :
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3551
						   HALF_DUPLEX;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3552
					retval = e1000_set_spd_dplx(adapter,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3553
								    spddplx);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3554
					if(retval) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3555
						spin_unlock_irqrestore(
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3556
							&adapter->stats_lock, 
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3557
							flags);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3558
						return retval;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3559
					}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3560
				}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3561
				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
  3562
					e1000_down(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3563
					e1000_up(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3564
				} else
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3565
					e1000_reset(adapter);
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
			case M88E1000_PHY_SPEC_CTRL:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3568
			case M88E1000_EXT_PHY_SPEC_CTRL:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3569
				if(e1000_phy_reset(&adapter->hw)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3570
					spin_unlock_irqrestore(
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3571
						&adapter->stats_lock, flags);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3572
					return -EIO;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3573
				}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3574
				break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3575
			}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3576
		} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3577
			switch (data->reg_num) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3578
			case PHY_CTRL:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3579
				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
  3580
					break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3581
				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
  3582
					e1000_down(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3583
					e1000_up(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3584
				} else
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3585
					e1000_reset(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3586
				break;
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
		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
  3590
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3591
	default:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3592
		return -EOPNOTSUPP;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3593
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3594
	return E1000_SUCCESS;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3595
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3596
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3597
void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3598
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
  3599
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3600
	struct e1000_adapter *adapter = hw->back;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3601
	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
  3602
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3603
	if(ret_val)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3604
		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
  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_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
  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_clear_mwi(adapter->pdev);
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_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
  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_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
  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
void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3624
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
  3625
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3626
	struct e1000_adapter *adapter = hw->back;
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
	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
  3629
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3630
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3631
uint32_t
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3632
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
  3633
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3634
	return inl(port);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3635
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3636
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3637
void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3638
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
  3639
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3640
	outl(value, port);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3641
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3642
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3643
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3644
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
  3645
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3646
	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
  3647
	uint32_t ctrl, rctl;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3648
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3649
	e1000_irq_disable(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3650
	adapter->vlgrp = grp;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3651
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3652
	if(grp) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3653
		/* enable VLAN tag insert/strip */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3654
		ctrl = E1000_READ_REG(&adapter->hw, CTRL);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3655
		ctrl |= E1000_CTRL_VME;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3656
		E1000_WRITE_REG(&adapter->hw, CTRL, ctrl);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3657
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3658
		/* enable VLAN receive filtering */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3659
		rctl = E1000_READ_REG(&adapter->hw, RCTL);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3660
		rctl |= E1000_RCTL_VFE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3661
		rctl &= ~E1000_RCTL_CFIEN;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3662
		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
  3663
		e1000_update_mng_vlan(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3664
	} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3665
		/* disable VLAN tag insert/strip */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3666
		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
  3667
		ctrl &= ~E1000_CTRL_VME;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3668
		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
  3669
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3670
		/* disable VLAN filtering */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3671
		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
  3672
		rctl &= ~E1000_RCTL_VFE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3673
		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
  3674
		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
  3675
			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
  3676
			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
  3677
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3678
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3679
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3680
	e1000_irq_enable(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3681
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3682
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3683
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3684
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
  3685
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3686
	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
  3687
	uint32_t vfta, index;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3688
	if((adapter->hw.mng_cookie.status &
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3689
		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
  3690
		(vid == adapter->mng_vlan_id))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3691
		return;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3692
	/* add VID to filter table */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3693
	index = (vid >> 5) & 0x7F;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3694
	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
  3695
	vfta |= (1 << (vid & 0x1F));
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3696
	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
  3697
}
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
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3700
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
  3701
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3702
	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
  3703
	uint32_t vfta, index;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3704
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3705
	e1000_irq_disable(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3706
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3707
	if(adapter->vlgrp)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3708
		adapter->vlgrp->vlan_devices[vid] = NULL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3709
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3710
	e1000_irq_enable(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3711
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3712
	if((adapter->hw.mng_cookie.status &
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3713
		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
  3714
		(vid == adapter->mng_vlan_id))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3715
		return;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3716
	/* remove VID from filter table */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3717
	index = (vid >> 5) & 0x7F;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3718
	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
  3719
	vfta &= ~(1 << (vid & 0x1F));
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3720
	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
  3721
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3722
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3723
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3724
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
  3725
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3726
	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
  3727
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3728
	if(adapter->vlgrp) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3729
		uint16_t vid;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3730
		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
  3731
			if(!adapter->vlgrp->vlan_devices[vid])
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3732
				continue;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3733
			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
  3734
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3735
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3736
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3737
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3738
int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3739
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
  3740
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3741
	adapter->hw.autoneg = 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3742
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3743
	/* 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
  3744
	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
  3745
		spddplx != (SPEED_1000 + DUPLEX_FULL)) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3746
		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
  3747
		return -EINVAL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3748
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3749
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3750
	switch(spddplx) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3751
	case SPEED_10 + DUPLEX_HALF:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3752
		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
  3753
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3754
	case SPEED_10 + DUPLEX_FULL:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3755
		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
  3756
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3757
	case SPEED_100 + DUPLEX_HALF:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3758
		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
  3759
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3760
	case SPEED_100 + DUPLEX_FULL:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3761
		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
  3762
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3763
	case SPEED_1000 + DUPLEX_FULL:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3764
		adapter->hw.autoneg = 1;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3765
		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
  3766
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3767
	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
  3768
	default:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3769
		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
  3770
		return -EINVAL;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3771
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3772
	return 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3773
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3774
724
f188f8a0cafd Include e1000_suspend() in #ifdef CONFIG_PM.
Florian Pose <fp@igh-essen.com>
parents: 677
diff changeset
  3775
#ifdef CONFIG_PM
673
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3776
static int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3777
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
  3778
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3779
	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
  3780
	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
  3781
	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
  3782
	uint32_t wufc = adapter->wol;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3783
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3784
	if (!adapter->ecdev)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3785
		netif_device_detach(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3786
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3787
	if (adapter->ecdev || netif_running(netdev))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3788
		e1000_down(adapter);
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
	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
  3791
	if(status & E1000_STATUS_LU)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3792
		wufc &= ~E1000_WUFC_LNKC;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3793
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3794
	if(wufc) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3795
		e1000_setup_rctl(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3796
		e1000_set_multi(netdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3797
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3798
		/* 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
  3799
		if(adapter->wol & E1000_WUFC_MC) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3800
			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
  3801
			rctl |= E1000_RCTL_MPE;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3802
			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
  3803
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3804
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3805
		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
  3806
			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
  3807
			/* advertise wake from D3Cold */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3808
			#define E1000_CTRL_ADVD3WUC 0x00100000
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3809
			/* phy power management enable */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3810
			#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
  3811
			ctrl |= E1000_CTRL_ADVD3WUC |
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3812
				E1000_CTRL_EN_PHY_PWR_MGMT;
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, ctrl);
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
		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
  3817
		   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
  3818
			/* keep the laser running in D3 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3819
			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
  3820
			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
  3821
			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
  3822
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3823
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3824
		/* 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
  3825
		e1000_disable_pciex_master(&adapter->hw);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3826
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3827
		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
  3828
		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
  3829
		pci_enable_wake(pdev, 3, 1);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3830
		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
  3831
	} else {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3832
		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
  3833
		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
  3834
		pci_enable_wake(pdev, 3, 0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3835
		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
  3836
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3837
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3838
	pci_save_state(pdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3839
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3840
	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
  3841
	   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
  3842
		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
  3843
		if(manc & E1000_MANC_SMBUS_EN) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3844
			manc |= E1000_MANC_ARP_EN;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3845
			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
  3846
			pci_enable_wake(pdev, 3, 1);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3847
			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
  3848
		}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3849
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3850
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3851
	switch(adapter->hw.mac_type) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3852
	case e1000_82573:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3853
		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
  3854
		E1000_WRITE_REG(&adapter->hw, SWSM,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3855
				swsm & ~E1000_SWSM_DRV_LOAD);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3856
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3857
	default:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3858
		break;
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
	pci_disable_device(pdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3862
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3863
	state = (state > 0) ? 3 : 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3864
	pci_set_power_state(pdev, state);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3865
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3866
	return 0;
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
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3869
static int
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3870
e1000_resume(struct pci_dev *pdev)
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3871
{
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3872
	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
  3873
	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
  3874
	uint32_t manc, ret_val, swsm;
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
	pci_set_power_state(pdev, 0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3877
	pci_restore_state(pdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3878
	ret_val = pci_enable_device(pdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3879
	pci_set_master(pdev);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3880
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3881
	pci_enable_wake(pdev, 3, 0);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3882
	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
  3883
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3884
	e1000_reset(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3885
	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
  3886
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3887
	if(adapter->ecdev || netif_running(netdev))
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3888
		e1000_up(adapter);
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
	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
  3891
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3892
	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
  3893
	   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
  3894
		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
  3895
		manc &= ~(E1000_MANC_ARP_EN);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3896
		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
  3897
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3898
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3899
	switch(adapter->hw.mac_type) {
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3900
	case e1000_82573:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3901
		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
  3902
		E1000_WRITE_REG(&adapter->hw, SWSM,
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3903
				swsm | E1000_SWSM_DRV_LOAD);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3904
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3905
	default:
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3906
		break;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3907
	}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3908
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3909
	return 0;
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3910
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3911
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3912
#ifdef CONFIG_NET_POLL_CONTROLLER
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3913
/*
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3914
 * 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
  3915
 * 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
  3916
 * the interrupt routine is executing.
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3917
 */
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3918
static void
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3919
e1000_netpoll(struct net_device *netdev)
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
	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
  3922
	disable_irq(adapter->pdev->irq);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3923
	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
  3924
	e1000_clean_tx_irq(adapter);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3925
	enable_irq(adapter->pdev->irq);
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3926
}
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3927
#endif
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3928
21c266c3f463 Added e1000 driver for kernel 2.6.13.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3929
/* e1000_main.c */